open class CompoundComparator<T : Any> : Comparator<T>, Serializable
A comparator that chains a sequence of one or 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.
Author
Keith Donald
Author
Juergen Hoeller
Since
1.2.2
CompoundComparator()
Construct a CompoundComparator with initially no Comparators. Clients must add at least one Comparator before calling the compare method or an IllegalStateException is thrown. CompoundComparator(vararg comparators: Comparator<Any>)
Construct a CompoundComparator from the Comparators in the provided array. All Comparators will default to ascending sort order, unless they are InvertibleComparators. |
open fun addComparator(comparator: Comparator<out T>): Unit
Add a Comparator to the end of the chain. The Comparator will default to ascending sort order, unless it is a InvertibleComparator. open fun addComparator(comparator: Comparator<out T>, ascending: Boolean): Unit
Add a Comparator to the end of the chain using the provided sort order. |
|
open fun compare(o1: T, o2: T): Int |
|
open fun equals(other: Any?): Boolean |
|
open fun getComparatorCount(): Int
Returns the number of aggregated comparators. |
|
open fun hashCode(): Int |
|
open fun invertOrder(): Unit
Invert the sort order of each sort definition contained by this compound comparator. open fun invertOrder(index: Int): Unit
Invert the sort order of the sort definition at the specified index. |
|
open fun setAscendingOrder(index: Int): Unit
Change the sort order at the given index to ascending. |
|
open fun setComparator(index: Int, comparator: Comparator<out T>): Unit
Replace the Comparator at the given index. The Comparator will default to ascending sort order, unless it is a InvertibleComparator. open fun setComparator(index: Int, comparator: Comparator<T>, ascending: Boolean): Unit
Replace the Comparator at the given index using the given sort order. |
|
open fun setDescendingOrder(index: Int): Unit
Change the sort order at the given index to descending sort. |
|
open fun toString(): String |