org.apache.commons.io.comparator

## Class ReverseFileComparator

- java.lang.Object
- - org.apache.commons.io.comparator.AbstractFileComparator
  - - org.apache.commons.io.comparator.ReverseFileComparator

- All Implemented Interfaces:
    Serializable, Comparator<File>

      final class ReverseFileComparator
      extends AbstractFileComparator
      implements Serializable

  Reverses the result of comparing two `File` objects using the delegate `Comparator`.

  ## Deprecating Serialization

  Serialization is deprecated and will be removed in 3.0.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReverseFileComparator(Comparator<File> delegate)` Constructs an instance with the specified delegate `Comparator`.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `compare(File file1, File file2)` Compares using the delegate Comparator, reversing the result.
    `String` | `toString()` Returns the String representation of this file comparator.

    - ### Methods inherited from class org.apache.commons.io.comparator.AbstractFileComparator

      `sort, sort`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Comparator

      `comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

- - ### Constructor Detail

    - #### ReverseFileComparator

          ReverseFileComparator(Comparator<File> delegate)

      Constructs an instance with the specified delegate `Comparator`.
      Parameters:
        `delegate` - The comparator to delegate to.

  - ### Method Detail

    - #### 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, 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.