public class InvertibleComparator<T>
extends java.lang.Object
implements java.util.Comparator<T>, java.io.Serializable
Constructor and Description |
---|
InvertibleComparator(java.util.Comparator<T> comparator)
Create an InvertibleComparator that sorts ascending by default.
|
InvertibleComparator(java.util.Comparator<T> comparator,
boolean ascending)
Create an InvertibleComparator that sorts based on the provided order.
|
Modifier and Type | Method and Description |
---|---|
int |
compare(T o1,
T o2) |
boolean |
equals(java.lang.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).
|
java.lang.String |
toString() |
public InvertibleComparator(java.util.Comparator<T> comparator)
comparator
- the comparator to decoratepublic InvertibleComparator(java.util.Comparator<T> comparator, boolean ascending)
comparator
- the comparator to decorateascending
- the sort order: ascending (true) or descending (false)public void setAscending(boolean ascending)
public boolean isAscending()
public void invertOrder()
public boolean equals(java.lang.Object obj)
equals
in interface java.util.Comparator<T>
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object