org.opencms.file.collectors
Class ComparatorInverter

java.lang.Object
  extended by org.opencms.file.collectors.ComparatorInverter
All Implemented Interfaces:
java.util.Comparator<I_CmsResource>

public final class ComparatorInverter
extends java.lang.Object
implements java.util.Comparator<I_CmsResource>

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

Constructor Summary
ComparatorInverter(java.util.Comparator<I_CmsResource> toInvert)
          Creates a comparator that will invert the result of the given comparator.
 
Method Summary
 int compare(I_CmsResource o1, I_CmsResource 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
 

Constructor Detail

ComparatorInverter

public ComparatorInverter(java.util.Comparator<I_CmsResource> toInvert)
Creates a comparator that will invert the result of the given comparator.

Parameters:
toInvert - the comparator to invert results of
Method Detail

compare

public int compare(I_CmsResource o1,
                   I_CmsResource o2)
Specified by:
compare in interface java.util.Comparator<I_CmsResource>
See Also:
Comparator.compare(java.lang.Object, java.lang.Object)