dsto.dfc.util
Class MixedTypeComparator
java.lang.Object
dsto.dfc.util.MixedTypeComparator
- All Implemented Interfaces:
- Comparator<Object>
public class MixedTypeComparator
- extends Object
- implements Comparator<Object>
A comparator that tries to intelligently order various mixed value
types. For cases where two compared values are the same type: uses
case-insenstive mode if both values are strings, otherwise tries to
use Comparable interface on either value, and then gives up with an
error. For cases where values are different types, it orders the
types into ordered categories of: numbers, strings, and everything
else categorised by hash code, This should work on collections of
strings, numbers and mutually comparable objects fairly well.
- Author:
- Matthew Phillips
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INSTANCE
public static final MixedTypeComparator INSTANCE
MixedTypeComparator
public MixedTypeComparator()
compare
public int compare(Object o1,
Object o2)
- Specified by:
compare
in interface Comparator<Object>
Copyright © 2008 Commonwealth of Australia