Class BooleanComparator

  • All Implemented Interfaces:
    java.util.Comparator<java.lang.Object>

    public class BooleanComparator
    extends java.lang.Object
    implements java.util.Comparator<java.lang.Object>
    Comparator for boolean type. This is a singleton class. Call getInstance() to get the comparator.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected BooleanComparator()
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.Object o1, java.lang.Object o2)
      Compares two Booleans.
      static BooleanComparator getInstance()
      Returns BooleanComparator singleton.
      • 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

      • BooleanComparator

        protected BooleanComparator()
        Constructor.

        Has protected access to prevent other clients creating instances of the class ... it is stateless so we need only one instance.

    • Method Detail

      • getInstance

        public static BooleanComparator getInstance()
        Returns BooleanComparator singleton.
        Returns:
        an instance of BooleanComparator.
      • compare

        public int compare​(java.lang.Object o1,
                           java.lang.Object o2)
        Compares two Booleans. False is treated as being less than True.
        Specified by:
        compare in interface java.util.Comparator<java.lang.Object>
        Parameters:
        o1 - the first object to be compared
        o2 - the second object to be compared
        Returns:
        0 if a and b are equal, -1 if a is less than b, 1 if a is more than b