Comparator.thenComparing(Comparator)@Deprecated public class CompoundComparator<T> extends Object implements Comparator<T>, Serializable
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.
| 构造器和说明 |
|---|
CompoundComparator()
已过时。
Construct a CompoundComparator with initially no Comparators.
|
CompoundComparator(Comparator... comparators)
已过时。
Construct a CompoundComparator from the Comparators in the provided array.
|
| 限定符和类型 | 方法和说明 |
|---|---|
void |
addComparator(Comparator<? extends T> comparator)
已过时。
Add a Comparator to the end of the chain.
|
void |
addComparator(Comparator<? extends T> comparator,
boolean ascending)
已过时。
Add a Comparator to the end of the chain using the provided sort order.
|
int |
compare(T o1,
T o2)
已过时。
|
boolean |
equals(Object other)
已过时。
|
int |
getComparatorCount()
已过时。
Returns the number of aggregated comparators.
|
int |
hashCode()
已过时。
|
void |
invertOrder()
已过时。
Invert the sort order of each sort definition contained by this compound
comparator.
|
void |
invertOrder(int index)
已过时。
Invert the sort order of the sort definition at the specified index.
|
void |
setAscendingOrder(int index)
已过时。
Change the sort order at the given index to ascending.
|
void |
setComparator(int index,
Comparator<? extends T> comparator)
已过时。
Replace the Comparator at the given index.
|
void |
setComparator(int index,
Comparator<T> comparator,
boolean ascending)
已过时。
Replace the Comparator at the given index using the given sort order.
|
void |
setDescendingOrder(int index)
已过时。
Change the sort order at the given index to descending sort.
|
String |
toString()
已过时。
|
public CompoundComparator()
public CompoundComparator(Comparator... comparators)
All Comparators will default to ascending sort order, unless they are InvertibleComparators.
comparators - the comparators to build into a compound comparatorInvertibleComparatorpublic void addComparator(Comparator<? extends T> comparator)
The Comparator will default to ascending sort order, unless it is a InvertibleComparator.
comparator - the Comparator to add to the end of the chainInvertibleComparatorpublic void addComparator(Comparator<? extends T> comparator, boolean ascending)
comparator - the Comparator to add to the end of the chainascending - the sort order: ascending (true) or descending (false)public void setComparator(int index,
Comparator<? extends T> comparator)
The Comparator will default to ascending sort order, unless it is a InvertibleComparator.
index - the index of the Comparator to replacecomparator - the Comparator to place at the given indexInvertibleComparatorpublic void setComparator(int index,
Comparator<T> comparator,
boolean ascending)
index - the index of the Comparator to replacecomparator - the Comparator to place at the given indexascending - the sort order: ascending (true) or descending (false)public void invertOrder()
public void invertOrder(int index)
index - the index of the comparator to invertpublic void setAscendingOrder(int index)
index - the index of the comparator to changepublic void setDescendingOrder(int index)
index - the index of the comparator to changepublic int getComparatorCount()
public int compare(T o1, T o2)
compare 在接口中 Comparator<T>public boolean equals(Object other)
equals 在接口中 Comparator<T>equals 在类中 Object