Class AnnotationComparator
- java.lang.Object
-
- psidev.psi.mi.jami.utils.comparator.annotation.AnnotationComparator
-
- All Implemented Interfaces:
Comparator<Annotation>
- Direct Known Subclasses:
UnambiguousAnnotationComparator
public class AnnotationComparator extends Object implements Comparator<Annotation>
Simple comparator for annotations It compares first the topics and then the value (case insensitive) - Two annotations which are null are equals - The annotation which is not null is before null. - use AbstractCvTermComparator to compare the topics. If they are equals, compares the values (case insensitive) - If both annotations have same topic, the one with a null value is always after the one with a non null value.- Since:
18/12/12
- Version:
- $Id$
- Author:
- Marine Dumousseau (marine@ebi.ac.uk)
-
-
Constructor Summary
Constructors Constructor Description AnnotationComparator(Comparator<CvTerm> topicComparator)
Creates a new AnnotationComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(Annotation annotation1, Annotation annotation2)
It compares first the topics and then the value (case insensitive) - Two annotations which are null are equals - The annotation which is not null is before null.Comparator<CvTerm>
getTopicComparator()
Getter for the fieldtopicComparator
.-
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
-
AnnotationComparator
public AnnotationComparator(Comparator<CvTerm> topicComparator)
Creates a new AnnotationComparator.- Parameters:
topicComparator
- : the CvTerm comparator to compare the topics. It is required
-
-
Method Detail
-
getTopicComparator
public Comparator<CvTerm> getTopicComparator()
Getter for the field
topicComparator
.- Returns:
- a
Comparator
object.
-
compare
public int compare(Annotation annotation1, Annotation annotation2)
It compares first the topics and then the value (case insensitive) - Two annotations which are null are equals - The annotation which is not null is before null. - use AbstractCvTermComparator to compare the topics. If they are equals, compares the values (case insensitive) - If both annotations have same topic, the one with a null value is always after the one with a non null value.- Specified by:
compare
in interfaceComparator<Annotation>
- Parameters:
annotation1
- : first annotationannotation2
- : second annotation- Returns:
- the comparison value
-
-