public CrossReference toCrossReference(O cvObject) { if (cvObject == null) { throw new IllegalArgumentException("CvObject must not be null. "); } // name of the cv is the fullname String text = cvObject.getFullName() != null ? cvObject.getFullName() : cvObject.getShortLabel(); String identity = cvObject.getIdentifier(); if (identity == null) { throw new NullPointerException( cvObject.getClass().getSimpleName() + "(" + text + ") didn't have an identity"); } final CvObjectXref idXref = findMatchingIdentityXref( cvObject.getXrefs(), identity); // XrefUtils.getIdentityXref(cvObject, CvDatabase.PSI_MI_MI_REF); if (idXref != null) { try { CrossReference ref = crossRefConverter.createCrossReference(idXref, false); ref.setText(text); return ref; } catch (Exception e) { throw new RuntimeException("An exception occured while building a cv object : " + text, e); } } else { CrossReference ref = new CrossReferenceImpl(CrossReferenceConverter.DATABASE_UNKNOWN, identity, text); return ref; } }