java.lang.Object | +--org.apache.commons.collections.ComparatorUtils
static Comparator | Comparator for natural sort order. |
ComparatorUtils should not normally be instantiated. |
static Comparator | booleanComparator(boolean trueFirst) Gets a Comparator that can sort Boolean objects. |
static Comparator | chainedComparator(Comparator comparator1, Comparator comparator2) Gets a comparator that compares using two Comparators. |
static Comparator | chainedComparator(Comparator[] comparators) Gets a comparator that compares using an array of Comparators, applied in sequence until one returns not equal or the array is exhausted. |
static Comparator | chainedComparator(Collection comparators) Gets a comparator that compares using a collection of Comparators, applied in (default iterator) sequence until one returns not equal or the collection is exhausted. |
static Object | max(Object o1, Object o2, Comparator comparator) Returns the larger of the given objects according to the given comparator, returning the second object if the comparator returns equal. |
static Object | min(Object o1, Object o2, Comparator comparator) Returns the smaller of the given objects according to the given comparator, returning the second object if the comparator returns equal. |
static Comparator | Gets a comparator that uses the natural order of the objects. |
static Comparator | nullHighComparator(Comparator comparator) Gets a Comparator that controls the comparison of null values. |
static Comparator | nullLowComparator(Comparator comparator) Gets a Comparator that controls the comparison of null values. |
static Comparator | reversedComparator(Comparator comparator) Gets a comparator that reverses the order of the given comparator. |
static Comparator | transformedComparator(Comparator comparator, Transformer transformer) Gets a Comparator that passes transformed objects to the given comparator. |
public static final Comparator NATURAL_COMPARATOR
ComparableComparator.getInstance
public ComparatorUtils()
public static Comparator booleanComparator(boolean trueFirst)
public static Comparator chainedComparator(Collection comparators)
- if comparators collection is null or contains a null
- if the comparators collection contains the wrong object typeComparatorChain
public static Comparator chainedComparator(Comparator comparator1, Comparator comparator2)
- if either comparator is nullComparatorChain
public static Comparator chainedComparator(Comparator[] comparators)
- if comparators array is null or contains a nullComparatorChain
public static Object max(Object o1, Object o2, Comparator comparator)
public static Object min(Object o1, Object o2, Comparator comparator)
public static Comparator naturalComparator()
public static Comparator nullHighComparator(Comparator comparator)
null
values.
The returned comparator will consider a null value to be greater than
any nonnull value, and equal to any other null value. Two nonnull
values will be evaluated with the given comparator.
NullComparator
public static Comparator nullLowComparator(Comparator comparator)
null
values.
The returned comparator will consider a null value to be less than
any nonnull value, and equal to any other null value. Two nonnull
values will be evaluated with the given comparator.
NullComparator
public static Comparator reversedComparator(Comparator comparator)
ReverseComparator
public static Comparator transformedComparator(Comparator comparator, Transformer transformer)
TransformingComparator
Comparator
objects. Most of the functionality in this class can also be found in thecomparators
package. This class merely provides a convenient central place if you have use for more than one class in thecomparators
subpackage.