Class ObjectComparators


  • public final class ObjectComparators
    extends java.lang.Object
    A class providing static methods and objects that do useful things with comparators.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <K> java.util.Comparator<K> asObjectComparator​(java.util.Comparator<K> c)
      Returns a the comparator given unmodified.
      static <K> java.util.Comparator<K> oppositeComparator​(java.util.Comparator<K> c)
      Returns a comparator representing the opposite order of the given comparator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • NATURAL_COMPARATOR

        public static final java.util.Comparator NATURAL_COMPARATOR
      • OPPOSITE_COMPARATOR

        public static final java.util.Comparator OPPOSITE_COMPARATOR
    • Method Detail

      • oppositeComparator

        public static <K> java.util.Comparator<K> oppositeComparator​(java.util.Comparator<K> c)
        Returns a comparator representing the opposite order of the given comparator.
        Parameters:
        c - a comparator.
        Returns:
        a comparator representing the opposite order of c.
      • asObjectComparator

        public static <K> java.util.Comparator<K> asObjectComparator​(java.util.Comparator<K> c)
        Returns a the comparator given unmodified. This method merely serves as a way to be compatible with primtive type-specific Comparators implementations, as they do have type-specific Comparators, but Object ones do not.
        Parameters:
        c - a comparator, or null.
        Returns:
        c, unmodified.