org.springframework.util.comparator

Class InvertibleComparator<T>

  • java.lang.Object
    • org.springframework.util.comparator.InvertibleComparator<T>
  • Type Parameters:
    T - the type of objects that may be compared by this comparator
    All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<T>

    Deprecated. 
    as of Spring Framework 5.0, in favor of the standard JDK 8 Comparator.reversed()

    @Deprecated
    public class InvertibleComparator<T>
    extends java.lang.Object
    implements java.util.Comparator<T>, java.io.Serializable
    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.
    Since:
    1.2.2
    Author:
    Keith Donald, Juergen Hoeller
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      InvertibleComparator(java.util.Comparator<T> comparator)
      Deprecated. 
      Create an InvertibleComparator that sorts ascending by default.
      InvertibleComparator(java.util.Comparator<T> comparator, boolean ascending)
      Deprecated. 
      Create an InvertibleComparator that sorts based on the provided order.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method and Description
      int compare(T o1, T o2)
      Deprecated. 
       
      boolean equals(java.lang.Object other)
      Deprecated. 
       
      int hashCode()
      Deprecated. 
       
      void invertOrder()
      Deprecated. 
      Invert the sort order: ascending -> descending or descending -> ascending.
      boolean isAscending()
      Deprecated. 
      Return the sort order: ascending (true) or descending (false).
      void setAscending(boolean ascending)
      Deprecated. 
      Specify the sort order: ascending (true) or descending (false).
      java.lang.String toString()
      Deprecated. 
       
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        comparing, comparing, comparingDouble, comparingInt, comparingLong, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • InvertibleComparator

        public InvertibleComparator(java.util.Comparator<T> comparator)
        Deprecated. 
        Create an InvertibleComparator that sorts ascending by default. For the actual comparison, the specified Comparator will be used.
        Parameters:
        comparator - the comparator to decorate
      • InvertibleComparator

        public InvertibleComparator(java.util.Comparator<T> comparator,
                                    boolean ascending)
        Deprecated. 
        Create an InvertibleComparator that sorts based on the provided order. For the actual comparison, the specified Comparator will be used.
        Parameters:
        comparator - the comparator to decorate
        ascending - the sort order: ascending (true) or descending (false)
    • Method Detail

      • setAscending

        public void setAscending(boolean ascending)
        Deprecated. 
        Specify the sort order: ascending (true) or descending (false).
      • isAscending

        public boolean isAscending()
        Deprecated. 
        Return the sort order: ascending (true) or descending (false).
      • invertOrder

        public void invertOrder()
        Deprecated. 
        Invert the sort order: ascending -> descending or descending -> ascending.
      • compare

        public int compare(T o1,
                           T o2)
        Deprecated. 
        Specified by:
        compare in interface java.util.Comparator<T>
      • equals

        public boolean equals(java.lang.Object other)
        Deprecated. 
        Specified by:
        equals in interface java.util.Comparator<T>
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Deprecated. 
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Deprecated. 
        Overrides:
        toString in class java.lang.Object