Class ReverseFileComparator

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator<java.io.File>

    class ReverseFileComparator
    extends AbstractFileComparator
    implements java.io.Serializable
    Reverses the result of comparing two File objects using the delegate Comparator.
    Since:
    1.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.Comparator<java.io.File> delegate  
      private static long serialVersionUID  
    • Constructor Summary

      Constructors 
      Constructor Description
      ReverseFileComparator​(java.util.Comparator<java.io.File> delegate)
      Construct an instance with the specified delegate Comparator.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.io.File file1, java.io.File file2)
      Compares using the delegate Comparator, reversing the result.
      java.lang.String toString()
      Returns the String representation of this file comparator.
      • Methods inherited from class java.lang.Object

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

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Field Detail

      • delegate

        private final java.util.Comparator<java.io.File> delegate
    • Constructor Detail

      • ReverseFileComparator

        public ReverseFileComparator​(java.util.Comparator<java.io.File> delegate)
        Construct an instance with the specified delegate Comparator.
        Parameters:
        delegate - The comparator to delegate to.
    • Method Detail

      • compare

        public int compare​(java.io.File file1,
                           java.io.File file2)
        Compares using the delegate Comparator, reversing the result.
        Specified by:
        compare in interface java.util.Comparator<java.io.File>
        Parameters:
        file1 - The first file to compare.
        file2 - The second file to compare.
        Returns:
        the result from the delegate Comparator.compare(Object, Object) reversing the value (i.e. positive becomes negative and vice versa).
      • toString

        public java.lang.String toString()
        Returns the String representation of this file comparator.
        Overrides:
        toString in class AbstractFileComparator
        Returns:
        String representation of this file comparator.