Class CvTermIdentifierComparator

  • All Implemented Interfaces:
    Comparator<CvTerm>

    public class CvTermIdentifierComparator
    extends Object
    implements Comparator<CvTerm>
    Cv term comparator that only takes into consideration identifiers. Will first look at MI identifiers, then MOD identifiers, then PAR identifiers and finally the full collection of identifiers . If both cv terms do not have any identifiers, it will consider them as identical
    Since:
    18/12/12
    Version:
    $Id$
    Author:
    Marine Dumousseau (marine@ebi.ac.uk)
    • Constructor Detail

      • CvTermIdentifierComparator

        public CvTermIdentifierComparator()
        Creates a new CvTermComparator with UnambiguousExternalIdentifierComparator
      • CvTermIdentifierComparator

        public CvTermIdentifierComparator​(Comparator<Xref> identifierComparator)

        Constructor for CvTermIdentifierComparator.

        Parameters:
        identifierComparator - a Comparator object.
      • CvTermIdentifierComparator

        public CvTermIdentifierComparator​(CollectionComparator<Xref> identifierComparator)

        Constructor for CvTermIdentifierComparator.

        Parameters:
        identifierComparator - a CollectionComparator object.
    • Method Detail

      • getIdentifierComparator

        public Comparator<Xref> getIdentifierComparator()

        Getter for the field identifierComparator.

        Returns:
        a Comparator 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 interface Comparator<CvTerm>
        Parameters:
        cvTerm1 - a CvTerm object.
        cvTerm2 - a CvTerm object.
        Returns:
        a int.
      • areEquals

        public static boolean areEquals​(CvTerm cv1,
                                        CvTerm cv2)
        Use UnambiguousCvTermComparator to know if two CvTerms are equals.
        Parameters:
        cv1 - a CvTerm object.
        cv2 - a CvTerm object.
        Returns:
        true if the two CvTerms are equal
      • hashCode

        public static int hashCode​(CvTerm cv1)

        hashCode

        Parameters:
        cv1 - a CvTerm object.
        Returns:
        the hashcode consistent with the equals method for this comparator