Class IDComparator

  • All Implemented Interfaces:
    java.util.Comparator<Unique>

    public class IDComparator
    extends java.lang.Object
    implements java.util.Comparator<Unique>
    A comparator imposing a total ordering on identifiable objects by comparing their ids.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.Comparator<Unique> DEFAULT
      The default IDComparator.
      static java.util.Comparator<Unique> INVERSE
      The default IDComparator, but with inverted order.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(Unique o1, Unique o2)
      Compares its two arguments for order according to their ids.
      • 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
    • Field Detail

      • DEFAULT

        public static final java.util.Comparator<Unique> DEFAULT
        The default IDComparator. We only has extrinsic state so we can use singleton here.
      • INVERSE

        public static final java.util.Comparator<Unique> INVERSE
        The default IDComparator, but with inverted order.
    • Method Detail

      • compare

        public int compare​(Unique o1,
                           Unique o2)
        Compares its two arguments for order according to their ids.
        Specified by:
        compare in interface java.util.Comparator<Unique>
        Returns:
        the natural ordering of o1's id and o2's id.