java.lang.Object | |
↳ | org.apache.commons.collections.ComparatorUtils |
Provides convenient static utility methods for Comparator
objects.
Most of the functionality in this class can also be found in the
comparators
package. This class merely provides a
convenient central place if you have use for more than one class
in the comparators
subpackage.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
NATURAL_COMPARATOR | Comparator for natural sort order. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
ComparatorUtils should not normally be instantiated.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets a Comparator that can sort Boolean objects.
| |||||||||||
Gets a comparator that compares using two
Comparator s. | |||||||||||
Gets a comparator that compares using a collection of
Comparator s,
applied in (default iterator) sequence until one returns not equal or the
collection is exhausted. | |||||||||||
Gets a comparator that compares using an array of
Comparator s, applied
in sequence until one returns not equal or the array is exhausted. | |||||||||||
Returns the larger of the given objects according to the given
comparator, returning the second object if the comparator
returns equal.
| |||||||||||
Returns the smaller of the given objects according to the given
comparator, returning the second object if the comparator
returns equal.
| |||||||||||
Gets a comparator that uses the natural order of the objects.
| |||||||||||
Gets a Comparator that controls the comparison of
null values. | |||||||||||
Gets a Comparator that controls the comparison of
null values. | |||||||||||
Gets a comparator that reverses the order of the given comparator.
| |||||||||||
Gets a Comparator that passes transformed objects to the given comparator.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
ComparatorUtils should not normally be instantiated.
Gets a Comparator that can sort Boolean objects.
The parameter specifies whether true or false is sorted first.
The comparator throws NullPointerException if a null value is compared.
trueFirst | when true , sort
true Booleans before
false Booleans. |
---|
Gets a comparator that compares using two Comparator
s.
The second comparator is used if the first comparator returns equal.
comparator1 | the first comparator to use, not null |
---|---|
comparator2 | the first comparator to use, not null |
ComparatorChain
formed from the two comparatorsNullPointerException | if either comparator is null |
---|
Gets a comparator that compares using a collection of Comparator
s,
applied in (default iterator) sequence until one returns not equal or the
collection is exhausted.
comparators | the comparators to use, not null or empty or containing nulls |
---|
ComparatorChain
formed from the input comparatorsNullPointerException | if comparators collection is null or contains a null |
---|---|
ClassCastException | if the comparators collection contains the wrong object type |
Gets a comparator that compares using an array of Comparator
s, applied
in sequence until one returns not equal or the array is exhausted.
comparators | the comparators to use, not null or empty or containing nulls |
---|
ComparatorChain
formed from the input comparatorsNullPointerException | if comparators array is null or contains a null |
---|
Returns the larger of the given objects according to the given comparator, returning the second object if the comparator returns equal.
o1 | the first object to compare |
---|---|
o2 | the second object to compare |
comparator | the sort order to use |
Returns the smaller of the given objects according to the given comparator, returning the second object if the comparator returns equal.
o1 | the first object to compare |
---|---|
o2 | the second object to compare |
comparator | the sort order to use |
Gets a comparator that uses the natural order of the objects.
Gets a Comparator that controls the comparison of 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.
comparator | the comparator that wants to allow nulls |
---|
Gets a Comparator that controls the comparison of 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.
comparator | the comparator that wants to allow nulls |
---|
Gets a comparator that reverses the order of the given comparator.
comparator | the comparator to reverse |
---|
Gets a Comparator that passes transformed objects to the given comparator.
Objects passed to the returned comparator will first be transformed by the given transformer before they are compared by the given comparator.
comparator | the sort order to use |
---|---|
transformer | the transformer to use |