Package org.plumelib.util
Class ToStringComparator
java.lang.Object
org.plumelib.util.ToStringComparator
- All Implemented Interfaces:
Comparator<Object>
A comparator that orders values based on the lexicographic ordering of their toString().
It handles null values, sorting them according to their printed representation "null".
-
Field Summary
Modifier and TypeFieldDescriptionstatic ToStringComparator
The unique instance (this class is a singleton). -
Method Summary
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
-
Field Details
-
instance
The unique instance (this class is a singleton).
-
-
Method Details
-
compare
- Specified by:
compare
in interfaceComparator<Object>
-
sorted
Returns a copy of the input, sorted according to the elements'toString()
.- Type Parameters:
T
- the type of the elements- Parameters:
in
- a set of elements- Returns:
- the elements, sorted according to
toString()
-