java.lang.Object | |
↳ | org.springframework.util.comparator.CompoundComparator<T> |
A comparator that chains a sequence of one or more more Comparators.
A compound comparator calls each Comparator in sequence until a single Comparator returns a non-zero result, or the comparators are exhausted and zero is returned.
This facilitates in-memory sorting similar to multi-column sorting in SQL. The order of any single Comparator in the list can also be reversed.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Construct a CompoundComparator with initially no Comparators.
| |||||||||||
Construct a CompoundComparator from the Comparators in the provided array.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a Comparator to the end of the chain.
| |||||||||||
Add a Comparator to the end of the chain using the provided sort order.
| |||||||||||
Returns the number of aggregated comparators.
| |||||||||||
Invert the sort order of each sort definition contained by this compound
comparator.
| |||||||||||
Invert the sort order of the sort definition at the specified index.
| |||||||||||
Change the sort order at the given index to ascending.
| |||||||||||
Replace the Comparator at the given index using the given sort order.
| |||||||||||
Replace the Comparator at the given index.
| |||||||||||
Change the sort order at the given index to descending sort.
| |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.util.Comparator
|
Construct a CompoundComparator with initially no Comparators. Clients must add at least one Comparator before calling the compare method or an IllegalStateException is thrown.
Construct a CompoundComparator from the Comparators in the provided array.
All Comparators will default to ascending sort order, unless they are InvertibleComparators.
comparators | the comparators to build into a compound comparator |
---|
Add a Comparator to the end of the chain.
The Comparator will default to ascending sort order, unless it is a InvertibleComparator.
comparator | the Comparator to add to the end of the chain |
---|
Add a Comparator to the end of the chain using the provided sort order.
comparator | the Comparator to add to the end of the chain |
---|---|
ascending | the sort order: ascending (true) or descending (false) |
Invert the sort order of each sort definition contained by this compound comparator.
Invert the sort order of the sort definition at the specified index.
index | the index of the comparator to invert |
---|
Change the sort order at the given index to ascending.
index | the index of the comparator to change |
---|
Replace the Comparator at the given index using the given sort order.
index | the index of the Comparator to replace |
---|---|
comparator | the Comparator to place at the given index |
ascending | the sort order: ascending (true) or descending (false) |
Replace the Comparator at the given index.
The Comparator will default to ascending sort order, unless it is a InvertibleComparator.
index | the index of the Comparator to replace |
---|---|
comparator | the Comparator to place at the given index |
Change the sort order at the given index to descending sort.
index | the index of the comparator to change |
---|