Class 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

      Constructors 
      Constructor Description
      ComparatorInverter​(java.util.Comparator<I_CmsResource> toInvert)
      Creates a comparator that will invert the result of the given comparator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • 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