Class NaturalComparator<T>

java.lang.Object
org.magicwerk.brownies.collections.helper.NaturalComparator<T>
Type Parameters:
T - element type
All Implemented Interfaces:
Serializable, Comparator<T>

public class NaturalComparator<T> extends Object
The NaturalComparator will compare object using their natural order.
See Also:
  • Method Details

    • getComparator

      public static <T> Comparator<T> getComparator(Class<T> clazz)
      Return the natural comparator for the class if it implements Comparable, otherwise null is returned.
      Parameters:
      clazz - class to get comparator for
      Returns:
      comparator for class, null if not available
    • INSTANCE

      public static <T> NaturalComparator<T> INSTANCE()
      Returns singleton instance.
    • INSTANCE

      public static <T> NaturalComparator<T> INSTANCE(Class<T> c)
      Returns singleton instance.
    • compare

      public int compare(T o1, T o2)
    • equals

      public boolean equals(Object that)
      Specified by:
      equals in interface Comparator<T>
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object