Class UnambiguousExternalIdentifierComparator

  • All Implemented Interfaces:
    Comparator<Xref>
    Direct Known Subclasses:
    ExactExternalIdentifierComparator

    public class UnambiguousExternalIdentifierComparator
    extends Object
    implements Comparator<Xref>
    Unambiguous comparator for external identifiers (Xref database and id). It compares first the databases and then the ids (case sensitive) but ignores the version. To compare the databases, it looks first at the PSI-MI id (the database with PSI-MI id will always come first), otherwise it looks at the database shortlabel only. If one database PSI-MI id is null, it will always comes after an Xref having a non null database PSI-MI id. - Two external identifiers which are null are equals - The external identifier which is not null is before null. - If the two external identifiers are set : - compare the databases. If both databases are equal, compare the ids (is case sensitive)
    Since:
    18/12/12
    Version:
    $Id$
    Author:
    Marine Dumousseau (marine@ebi.ac.uk)
    • Constructor Detail

      • UnambiguousExternalIdentifierComparator

        public UnambiguousExternalIdentifierComparator()

        Constructor for UnambiguousExternalIdentifierComparator.

    • Method Detail

      • compare

        public int compare​(Xref externalIdentifier1,
                           Xref externalIdentifier2)
        It compares first the databases and then the ids (case sensitive) but ignores the version. To compare the databases, it looks first at the PSI-MI id (the database with PSI-MI id will always come first), otherwise it looks at the database shortlabel only. If one database PSI-MI id is null, it will always comes after an Xref having a non null database PSI-MI id. - Two external identifiers which are null are equals - The external identifier which is not null is before null. - If the two external identifiers are set : - compare the databases. If both databases are equal, compare the ids (is case sensitive)
        Specified by:
        compare in interface Comparator<Xref>
        Parameters:
        externalIdentifier1 - a Xref object.
        externalIdentifier2 - a Xref object.
        Returns:
        a int.
      • areEquals

        public static boolean areEquals​(Xref externalIdentifier1,
                                        Xref externalIdentifier2)
        Use UnambiguousIdentifierComparator to know if two external identifiers are equals.
        Parameters:
        externalIdentifier1 - a Xref object.
        externalIdentifier2 - a Xref object.
        Returns:
        true if the two external identifiers are equal
      • hashCode

        public static int hashCode​(Xref externalIdentifier1)

        hashCode

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