|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.util.comparator.InvertibleComparator<T>
public class InvertibleComparator<T>
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.
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public InvertibleComparator(Comparator<T> comparator)
comparator
- the comparator to decoratepublic InvertibleComparator(Comparator<T> comparator, boolean ascending)
comparator
- the comparator to decorateascending
- the sort order: ascending (true) or descending (false)Method Detail |
---|
public void setAscending(boolean ascending)
public boolean isAscending()
public void invertOrder()
public int compare(T o1, T o2)
compare
in interface Comparator<T>
public boolean equals(Object obj)
equals
in interface Comparator<T>
equals
in class Object
public int hashCode()
hashCode
in class Object
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |