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 delegate Comparator
.
- Since:
- Commons IO 1.4
- Version:
- $Revision: 1021884 $ $Date: 2010-10-12 14:49:16 -0400 (Tue, 12 Oct 2010) $
Field Summary |
private java.util.Comparator<java.io.File> |
delegate
|
Constructor Summary |
ReverseComparator(java.util.Comparator<java.io.File> delegate)
Construct an instance with the sepecified delegate Comparator . |
Method Summary |
int |
compare(java.io.File file1,
java.io.File file2)
Compare using the delegate Comparator, but reversing the result. |
java.lang.String |
toString()
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 |
delegate
private final java.util.Comparator<java.io.File> delegate
ReverseComparator
public ReverseComparator(java.util.Comparator<java.io.File> delegate)
- Construct an instance with the sepecified delegate
Comparator
.
- Parameters:
delegate
- The comparator to delegate to
compare
public int compare(java.io.File file1,
java.io.File file2)
- Compare using the delegate Comparator, but reversing the result.
- Specified by:
compare
in interface java.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:
toString
in class AbstractFileComparator
- Returns:
- String representation of this file comparator
Copyright (c) 2002-2012 Apache Software Foundation