Package com.jidesoft.comparator
Class DefaultComparator
- java.lang.Object
-
- com.jidesoft.comparator.DefaultComparator
-
- All Implemented Interfaces:
java.util.Comparator<java.lang.Object>
public class DefaultComparator extends java.lang.Object implements java.util.Comparator<java.lang.Object>Badly named, this class compares objects by first converting them to Strings using the toString method.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedDefaultComparator()Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.lang.Object o1, java.lang.Object o2)Compares two Objects using the toString() method as the value of each object to compare.static DefaultComparatorgetInstance()Returns ObjectComparator singleton.
-
-
-
Method Detail
-
getInstance
public static DefaultComparator getInstance()
Returns ObjectComparator singleton.- Returns:
- an instance of DefaultComparator.
-
compare
public int compare(java.lang.Object o1, java.lang.Object o2)Compares two Objects using the toString() method as the value of each object to compare.- Specified by:
comparein interfacejava.util.Comparator<java.lang.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 < b, grater than 0 if a > b.
-
-