Package 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>
Reverses the result of comparing two
File
objects using the delegate Comparator
.
Deprecating Serialization
Serialization is deprecated and will be removed in 3.0.
- Since:
- 1.4
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionReverseFileComparator
(Comparator<File> delegate) Constructs an instance with the specified delegateComparator
. -
Method Summary
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
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
delegate
-
-
Constructor Details
-
ReverseFileComparator
Constructs an instance with the specified delegateComparator
.- Parameters:
delegate
- The comparator to delegate to.
-
-
Method Details
-
compare
Compares using the delegate Comparator, reversing the result.- Specified by:
compare
in interfaceComparator<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
Returns the String representation of this file comparator.- Overrides:
toString
in classAbstractFileComparator
- Returns:
- String representation of this file comparator.
-