Class Comparators


  • final class Comparators
    extends java.lang.Object
    INTERNAL: Common Comparator related functions (not intended to be public).
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private Comparators()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static <U> java.util.Comparator<U> naturalComparator()
      Returns the natural comparator for type U, i.e.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Comparators

        private Comparators()
    • Method Detail

      • naturalComparator

        static <U> java.util.Comparator<U> naturalComparator()
        Returns the natural comparator for type U, i.e. treating it as Comparable<U>. The returned comparator is also java.io.Serializable.

        Please note that this will lead to runtime exceptions, if U is not Comparable.

        Type Parameters:
        U - The type
        Returns:
        The natural Comparator of type U