类 InvertibleComparator<T>
- java.lang.Object
- org.springframework.util.comparator.InvertibleComparator<T>
- 所有已实现的接口:
Serializable
,Comparator<T>
public class InvertibleComparator<T> extends Object implements Comparator<T>, Serializable
A decorator for a comparator, with an "ascending" flag denoting whether comparison results should be treated in forward (standard ascending) order or flipped for reverse (descending) order.- 从以下版本开始:
- 1.2.2
- 作者:
- Keith Donald, Juergen Hoeller
- 另请参阅:
- 序列化表格
构造器概要
构造器 构造器 说明 InvertibleComparator(Comparator<T> comparator)
Create an InvertibleComparator that sorts ascending by default.InvertibleComparator(Comparator<T> comparator, boolean ascending)
Create an InvertibleComparator that sorts based on the provided order.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 int
compare(T o1, T o2)
boolean
equals(Object obj)
int
hashCode()
void
invertOrder()
Invert the sort order: ascending -> descending or descending -> ascending.boolean
isAscending()
Return the sort order: ascending (true) or descending (false).void
setAscending(boolean ascending)
Specify the sort order: ascending (true) or descending (false).String
toString()
从接口继承的方法 java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
构造器详细资料
InvertibleComparator
public InvertibleComparator(Comparator<T> comparator)
Create an InvertibleComparator that sorts ascending by default. For the actual comparison, the specified Comparator will be used.- 参数:
comparator
- the comparator to decorate
InvertibleComparator
public InvertibleComparator(Comparator<T> comparator, boolean ascending)
Create an InvertibleComparator that sorts based on the provided order. For the actual comparison, the specified Comparator will be used.- 参数:
comparator
- the comparator to decorateascending
- the sort order: ascending (true) or descending (false)
方法详细资料
setAscending
public void setAscending(boolean ascending)
Specify the sort order: ascending (true) or descending (false).
isAscending
public boolean isAscending()
Return the sort order: ascending (true) or descending (false).
invertOrder
public void invertOrder()
Invert the sort order: ascending -> descending or descending -> ascending.