org.opencms.file.collectors
Class ComparatorInverter
java.lang.Object
org.opencms.file.collectors.ComparatorInverter
- All Implemented Interfaces:
- java.util.Comparator
public final class ComparatorInverter
- extends java.lang.Object
- implements java.util.Comparator
Wrapper around a comparator that inverts comparison results which may e.g. be
used to invert sort orders.
This is used to create SortedSet instances that may
sort in different order (ascending vs. descending).
| Internal comparator result |
Transformed result |
| -1 |
+1 |
| 0 |
0 |
| +1 |
-1 |
- Since:
- 7.0.3
- Author:
- Achim Westermann
|
Constructor Summary |
ComparatorInverter(java.util.Comparator toInvert)
Creates a comparator that will invert the result of the given comparator. |
|
Method Summary |
int |
compare(java.lang.Object o1,
java.lang.Object o2)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
equals |
ComparatorInverter
public ComparatorInverter(java.util.Comparator toInvert)
- Creates a comparator that will invert the result of the given comparator.
- Parameters:
toInvert - the comparator to invert results of
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare in interface java.util.Comparator
- See Also:
Comparator.compare(java.lang.Object, java.lang.Object)