Class UnambiguousXrefComparator
- java.lang.Object
-
- psidev.psi.mi.jami.utils.comparator.xref.UnambiguousXrefComparator
-
- All Implemented Interfaces:
Comparator<Xref>
- Direct Known Subclasses:
ExactXrefComparator
public class UnambiguousXrefComparator extends Object implements Comparator<Xref>
Strict Xref comparator 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.- Since:
19/12/12
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description UnambiguousXrefComparator()
Constructor for UnambiguousXrefComparator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static boolean
areEquals(Xref xref1, Xref xref2)
Use UnambiguousXrefComparator to know if two xrefs are equals.int
compare(Xref xref1, Xref xref2)
It compares first the databases and then the ids (case sensitive) but ignores the version.static int
hashCode(Xref xref)
hashCode-
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
-
-
-
-
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.- Specified by:
compare
in interfaceComparator<Xref>
- Parameters:
xref1
- aXref
object.xref2
- aXref
object.- Returns:
- a int.
-
areEquals
public static boolean areEquals(Xref xref1, Xref xref2)
Use UnambiguousXrefComparator to know if two xrefs are equals.
-
-