X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/57ea5ac14609e6b73a69d048e4b2379425cf2123..266bc333891e138d7ead1e6d2dc72d2653d0fc6c:/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationship.java diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationship.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationship.java index 8c3925714a..c4cc412f05 100644 --- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationship.java +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/HybridRelationship.java @@ -26,7 +26,7 @@ import org.hibernate.annotations.CascadeType; import org.hibernate.envers.Audited; import eu.etaxonomy.cdm.model.common.RelationshipBase; -import eu.etaxonomy.cdm.model.reference.ReferenceBase; +import eu.etaxonomy.cdm.model.reference.Reference; /** * The class representing a hybrid relationship between one of the {@link BotanicalName parents} @@ -55,9 +55,7 @@ import eu.etaxonomy.cdm.model.reference.ReferenceBase; }) @Entity @Audited -public class HybridRelationship extends RelationshipBase { - - @SuppressWarnings("unused") +public class HybridRelationship extends RelationshipBase implements Cloneable, Comparable{ private static final Logger logger = Logger.getLogger(HybridRelationship.class); //The nomenclatural code rule considered. The article/note/recommendation in the code in question that is commented on in @@ -85,8 +83,10 @@ public class HybridRelationship extends RelationshipBase related2 = rel2.getRelatedFrom(); + if (related1 != related2){ + related1 = this.getRelatedTo(); + related2 = rel2.getRelatedTo(); + } + String title1 = related1.getTitleCache(); + String title2 = related2.getTitleCache(); + return title1.compareTo(title2); + } + } + + +//*********************** CLONE ********************************************************/ + + /** + * Clones this hybrid relationship. This is a shortcut that enables to create + * a new instance that differs only slightly from this hybrid relationship by + * modifying only some of the attributes.
+ * CAUTION: Cloning a relationship will not add the relationship to the according + * {@link #relatedFrom} and {@link #relatedTo} objects. The method is meant to be used + * mainly for internal purposes (e.g. used within {@link TaxonNameBase#clone()} + * + * @see eu.etaxonomy.cdm.model.common.RelationshipBase#clone() + * @see java.lang.Object#clone() + */ + @Override + public Object clone() { + HybridRelationship result; + try { + result = (HybridRelationship)super.clone(); + //no changes to: relatedFrom, relatedTo, type + return result; + } catch (CloneNotSupportedException e) { + logger.warn("Object does not implement cloneable"); + e.printStackTrace(); + return null; + } + } + } \ No newline at end of file