Class NaturalComparator<T>
java.lang.Object
org.magicwerk.brownies.collections.helper.SingletonComparator<T>
org.magicwerk.brownies.collections.helper.NaturalComparator<T>
- Type Parameters:
T
- element type
- All Implemented Interfaces:
Serializable
,Comparator<T>
The NaturalComparator will compare object using their natural order.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
static <T> Comparator
<T> getComparator
(Class<T> clazz) Return the natural comparator for the class if it implements Comparable, otherwise null is returned.static <T> NaturalComparator
<T> INSTANCE()
Returns singleton instance.static <T> NaturalComparator
<T> Returns singleton instance.Methods inherited from class org.magicwerk.brownies.collections.helper.SingletonComparator
equals, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
INSTANCE
Singleton instance.
-
-
Constructor Details
-
NaturalComparator
private NaturalComparator()Prevent construction.
-
-
Method Details
-
getComparator
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
Returns singleton instance. -
INSTANCE
Returns singleton instance. -
compare
-