Class ExactXrefComparator

  • All Implemented Interfaces:
    Comparator<Xref>

    public class ExactXrefComparator
    extends UnambiguousXrefComparator
    Exact comparator for Xrefs. It compares first the databases using UnambiguousCvTermComparator, then the ids (case sensitive) and then the version. To compare the databases, it looks first at the identifiers id if they both exist, otherwise it looks at the database shortlabel only. - 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) - if both ids are the same, compares the versions. - If both xref databases and ids are the same, use UnambiguousCvTermComparator to compare the qualifiers.
    Since:
    20/12/12
    Version:
    $Id$
    Author:
    Marine Dumousseau (marine@ebi.ac.uk)
    • Constructor Detail

      • ExactXrefComparator

        public ExactXrefComparator()

        Constructor for ExactXrefComparator.

    • Method Detail

      • compare

        public int compare​(Xref xref1,
                           Xref xref2)
        It compares first the databases and then the ids (case sensitive) but ignores the version. To compare the databases, it looks first at the identifiers id (the database with identifier will always come first), otherwise it looks at the database shortlabel only. If one database identifier is null, it will always comes after an ExternalIdentifier having a non null database id. Then it will compare the qualifier. To compare the qualifiers, it looks first at the identifiers id if they both exist, otherwise it looks at the qualifier shortnames only. If one qualifier identifier is null, it will always comes after a Xref having a non null qualifiers id. - Two xrefs which are null are equals - The xref which is not null is before null. - Use UnambiguousExternalIdentifierComparator to compare first the database and id. - If both xref databases and ids are the same, compare the qualifiers. It compares first the databases using UnambiguousCvTermComparator, then the ids (case sensitive) and then the version. To compare the databases, it looks first at the identifiers id if they both exist, otherwise it looks at the database shortlabel only. - 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) - if both ids are the same, compares the versions. - If both xref databases and ids are the same, use UnambiguousCvTermComparator to compare the qualifiers.
        Specified by:
        compare in interface Comparator<Xref>
        Overrides:
        compare in class UnambiguousXrefComparator
        Parameters:
        xref1 - a Xref object.
        xref2 - a Xref object.
        Returns:
        a int.
      • areEquals

        public static boolean areEquals​(Xref xref1,
                                        Xref xref2)
        Use ExactXrefComparator to know if two xrefs are equals.
      • hashCode

        public static int hashCode​(Xref xref)