Package org.apache.commons.io.comparator
Class ReverseComparator
- java.lang.Object
-
- org.apache.commons.io.comparator.AbstractFileComparator
-
- org.apache.commons.io.comparator.ReverseComparator
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator<java.io.File>
class ReverseComparator extends AbstractFileComparator implements java.io.Serializable
Reverses the result of comparing two objects using the delegateComparator.- Since:
- 1.4
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Comparator<java.io.File>delegateprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description ReverseComparator(java.util.Comparator<java.io.File> delegate)Construct an instance with the specified delegateComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(java.io.File file1, java.io.File file2)Compare using the delegate Comparator, but reversing the result.java.lang.StringtoString()String representation of this file comparator.-
Methods inherited from class org.apache.commons.io.comparator.AbstractFileComparator
sort, sort
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
delegate
private final java.util.Comparator<java.io.File> delegate
-
-
Method Detail
-
compare
public int compare(java.io.File file1, java.io.File file2)Compare using the delegate Comparator, but reversing the result.- Specified by:
comparein interfacejava.util.Comparator<java.io.File>- Parameters:
file1- The first file to comparefile2- 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()
String representation of this file comparator.- Overrides:
toStringin classAbstractFileComparator- Returns:
- String representation of this file comparator
-
-