Class CvTermComparator
- java.lang.Object
-
- psidev.psi.mi.jami.utils.comparator.cv.CvTermComparator
-
- All Implemented Interfaces:
Comparator<CvTerm>
- Direct Known Subclasses:
UnambiguousCvTermComparator
public class CvTermComparator extends Object implements Comparator<CvTerm>
comparator for CvTerms : If one CvTerm does not have any identifiers, it will only compare the short names (case insensitive). If both CvTerm objects have identifiers, it will look for exact same collection of identifiers using UnambiguousExternalIdentifierComparator and ignores all the other properties. - Two CvTerms which are null are equals - The CvTerm which is not null is before null. - If the two external identifiers are set, use UnambiguousExternalIdentifier comparator - The CvTerm without an external identifier is after the CvTerm with an identifier (do not compare short names if we have one external identifier) - When both CvTerms do not have an external identifier, it compares the short names (case insensitive) which cannot be null- Since:
18/12/12
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description CvTermComparator(Comparator<Xref> identifierComparator)
Creates a new CvTermComparator with UnambiguousExternalIdentifierComparatorCvTermComparator(CollectionComparator<Xref> identifierComparator)
Constructor for CvTermComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(CvTerm cvTerm1, CvTerm cvTerm2)
If one CvTerm does not have any identifiers, it will only compare the short names (case insensitive).CollectionComparator<Xref>
getIdentifierCollectionComparator()
Getter for the fieldidentifierCollectionComparator
.Comparator<Xref>
getIdentifierComparator()
Getter for the fieldidentifierComparator
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
CvTermComparator
public CvTermComparator(Comparator<Xref> identifierComparator)
Creates a new CvTermComparator with UnambiguousExternalIdentifierComparator- Parameters:
identifierComparator
- aComparator
object.
-
CvTermComparator
public CvTermComparator(CollectionComparator<Xref> identifierComparator)
Constructor for CvTermComparator.
- Parameters:
identifierComparator
- aCollectionComparator
object.
-
-
Method Detail
-
getIdentifierComparator
public Comparator<Xref> getIdentifierComparator()
Getter for the field
identifierComparator
.- Returns:
- a
Comparator
object.
-
getIdentifierCollectionComparator
public CollectionComparator<Xref> getIdentifierCollectionComparator()
Getter for the field
identifierCollectionComparator
.- Returns:
- a
CollectionComparator
object.
-
compare
public int compare(CvTerm cvTerm1, CvTerm cvTerm2)
If one CvTerm does not have any identifiers, it will only compare the short names (case insensitive). If both CvTerm objects have identifiers, it will look for exact same collection of identifiers using UnambiguousExternalIdentifierComparator and ignores all the other properties. - Two CvTerms which are null are equals - The CvTerm which is not null is before null. - If the two external identifiers are set, use UnambiguousExternalIdentifier comparator - The CvTerm without an external identifier is after the CvTerm with an identifier (do not compare short names if we have one external identifier) - When both CvTerms do not have an external identifier, it compares the short names (case insensitive) which cannot be null- Specified by:
compare
in interfaceComparator<CvTerm>
- Parameters:
cvTerm1
- aCvTerm
object.cvTerm2
- aCvTerm
object.- Returns:
- a int.
-
-