Class ReverseFileComparator

java.lang.Object
org.apache.commons.io.comparator.AbstractFileComparator
org.apache.commons.io.comparator.ReverseFileComparator
All Implemented Interfaces:
Serializable, Comparator<File>

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

  • Constructor Details

    • ReverseFileComparator

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

    • compare

      public int compare(File file1, File file2)
      Compares using the delegate Comparator, reversing the result.
      Specified by:
      compare in interface Comparator<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 String toString()
      Returns the String representation of this file comparator.
      Overrides:
      toString in class AbstractFileComparator
      Returns:
      String representation of this file comparator.