Package com.jidesoft.comparator
Class DefaultComparator
java.lang.Object
com.jidesoft.comparator.DefaultComparator
- All Implemented Interfaces:
Comparator<Object>
Badly named, this class compares objects by first converting them to Strings using the
toString method.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
Compares two Objects using the toString() method as the value of each object to compare.static DefaultComparator
Returns ObjectComparator singleton.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
-
Constructor Details
-
DefaultComparator
protected DefaultComparator()Constructor. Has protected access to prevent other clients creating instances of the class ... it is stateless so we need only one instance.
-
-
Method Details
-
getInstance
Returns ObjectComparator singleton.- Returns:
- an instance of DefaultComparator.
-
compare
Compares two Objects using the toString() method as the value of each object to compare.- Specified by:
compare
in interfaceComparator<Object>
- Parameters:
o1
- the first object to be comparedo2
- the second object to be compared- Returns:
- 0 if a and b are equal, less than 0 if a invalid input: '<' b, grater than 0 if a > b.
-