Class UnambiguousPositionComparator

  • All Implemented Interfaces:
    Comparator<Position>

    public class UnambiguousPositionComparator
    extends PositionComparator
    Strict PositionComparator. It will first compare the status (using UnambiguousCvTermComparator) and then will check if the position is undetermined. It will then check the start and the end. - Two positions which are null are equals - The position which is not null is before null. - Use UnambiguousCvTermComparator to compare first the position status. - If position status are equals, the undetermined positions are always coming after the determined positions. - If both positions have same status and are undetermined, they are equals - If both positions are not undetermined, compare the start position first and then the end position
    Since:
    19/12/12
    Version:
    $Id$
    Author:
    Marine Dumousseau (marine@ebi.ac.uk)
    • Constructor Detail

      • UnambiguousPositionComparator

        public UnambiguousPositionComparator()
        Creates a new positionComparator with UnambiguousCvTermComparator
    • Method Detail

      • compare

        public int compare​(Position position1,
                           Position position2)
        It will first compare the status and then will check if the position is undetermined. It will then check the start and the end. - Two positions which are null are equals - The position which is not null is before null. - An undetermined position always comes after a determined position - Two undetermined positions with same status are equals (no need to look at the positions start and end) It will first compare the status (using UnambiguousCvTermComparator) and then will check if the position is undetermined. It will then check the start and the end. - Two positions which are null are equals - The position which is not null is before null. - Use UnambiguousCvTermComparator to compare first the position status. - If position status are equals, the undetermined positions are always coming after the determined positions. - If both positions have same status and are undetermined, they are equals - If both positions are not undetermined, compare the start position first and then the end position
        Specified by:
        compare in interface Comparator<Position>
        Overrides:
        compare in class PositionComparator
        Parameters:
        position1 - a Position object.
        position2 - a Position object.
        Returns:
        a int.
      • areEquals

        public static boolean areEquals​(Position pos1,
                                        Position pos2)
        Use UnabmbiguousPositionComparator to know if two positions are equals.
        Parameters:
        pos1 - a Position object.
        pos2 - a Position object.
        Returns:
        true if the two positions are equal
      • hashCode

        public static int hashCode​(Position pos)

        hashCode

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