org.apache.commons.io.comparator

Class ReverseComparator

Implemented Interfaces:
Comparator, Serializable

(package private) class ReverseComparator
extends java.lang.Object
implements Comparator, Serializable

Reverses the result of comparing two objects using the delegate Comparator.
Version:
$Revision: 609243 $ $Date: 2008-01-06 00:30:42 +0000 (Sun, 06 Jan 2008) $
Since:
Commons IO 1.4

Field Summary

private Comparator
delegate

Constructor Summary

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

Method Summary

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

Field Details

delegate

private final Comparator delegate

Constructor Details

ReverseComparator

public ReverseComparator(Comparator delegate)
Construct an instance with the sepecified delegate Comparator.
Parameters:
delegate - The comparator to delegate to

Method Details

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-2008 Apache Software Foundation