Class 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 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 interface Comparator<Annotation>
        Parameters:
        annotation1 - : first annotation
        annotation2 - : second annotation
        Returns:
        the comparison value