private static <X extends Xref> X newXrefInstance(Class<X> xrefClass, CvDatabase db, String primaryId, String secondaryId, String dbRelease, CvXrefQualifier cvXrefQual) { X xref = null; try { xref = xrefClass.newInstance(); xref.setCvDatabase(db); xref.setPrimaryId(primaryId); xref.setSecondaryId(secondaryId); xref.setDbRelease(dbRelease); xref.setCvXrefQualifier(cvXrefQual); } catch (Exception e) { throw new PsiConversionException(e); } return xref; }
/** * Note: this does not clone the parent. * * @param xref * @return * @throws uk.ac.ebi.intact.model.clone.IntactClonerException * */ protected Xref cloneXref(Xref xref) throws IntactClonerException { if (xref == null) return null; Class clazz = CgLibUtil.removeCglibEnhanced(xref.getClass()); Xref clone = null; try { final Constructor constructor = clazz.getConstructor(); clone = (Xref) constructor.newInstance(); clonerManager.addClone(xref, clone); clone.setPrimaryId(xref.getPrimaryId()); clone.setSecondaryId(xref.getSecondaryId()); clone.setDbRelease(xref.getDbRelease()); clone.setCvDatabase(clone(xref.getCvDatabase())); clone.setCvXrefQualifier(clone(xref.getCvXrefQualifier())); } catch (Exception e) { throw new IntactClonerException("An error occured upon building a " + clazz.getSimpleName(), e); } clone.setParent(clone(xref.getParent())); return clone; }
/** * Note: this does not clone the parent. * * @param xref * @return * @throws uk.ac.ebi.intact.model.clone.IntactClonerException * */ protected Xref cloneXref(Xref xref) throws IntactClonerException { if (xref == null) return null; Class clazz = CgLibUtil.removeCglibEnhanced(xref.getClass()); Xref clone = null; try { final Constructor constructor = clazz.getConstructor(); clone = (Xref) constructor.newInstance(); clonerManager.addClone(xref, clone); clone.setPrimaryId(xref.getPrimaryId()); clone.setSecondaryId(xref.getSecondaryId()); clone.setDbRelease(xref.getDbRelease()); clone.setCvDatabase(clone(xref.getCvDatabase())); clone.setCvXrefQualifier(clone(xref.getCvXrefQualifier())); } catch (Exception e) { throw new IntactClonerException("An error occured upon building a " + clazz.getSimpleName(), e); } clone.setParent(clone(xref.getParent())); return clone; }