org.apache.commons.io.comparator

Class ReverseComparator

class ReverseComparator extends Object implements Comparator, Serializable

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

Since: Commons IO 1.4

Version: $Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $

Field Summary
Comparatordelegate
Constructor Summary
ReverseComparator(Comparator delegate)
Construct an instance with the sepecified delegate Comparator.
Method Summary
intcompare(Object obj1, Object obj2)
Compare using the delegate Comparator, but reversing the result.

Field Detail

delegate

private final Comparator delegate

Constructor Detail

ReverseComparator

public ReverseComparator(Comparator delegate)
Construct an instance with the sepecified delegate Comparator.

Parameters: delegate The comparator to delegate to

Method Detail

compare

public int compare(Object obj1, Object obj2)
Compare using the delegate Comparator, but reversing the result.

Parameters: obj1 The first object to compare obj2 The second object to compare

Returns: the result from the delegate Comparator#compare(Object, Object) reversing the value (i.e. positive becomes negative and vice versa)

Copyright (c) 2002-2011 Apache Software Foundation