org.apache.commons.collections.comparators
Class ReverseComparator

java.lang.Object
  |
  +--org.apache.commons.collections.comparators.ReverseComparator
All Implemented Interfaces:
Comparator, Serializable

public class ReverseComparator
extends Object
implements Comparator, Serializable

Reverses the order of another comparator.

Since:
2.0
Version:
$Id: ReverseComparator.java,v 1.8 2002/06/12 03:59:17 mas Exp $
Author:
bayard@generationjava.com, Michael A. Smith
See Also:
Serialized Form

Constructor Summary
ReverseComparator()
          Creates a comparator that compares objects based on the inverse of their natural ordering.
ReverseComparator(Comparator comparator)
          Creates a reverse comparator that inverts the comparison of the passed in comparator.
 
Method Summary
 int compare(Object o1, Object o2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

ReverseComparator

public ReverseComparator()
Creates a comparator that compares objects based on the inverse of their natural ordering. Using this Constructor will create a ReverseComparator that is functionaly identical to the Comparator returned by java.util.Collections.reverseOrder().

See Also:
Collections.reverseOrder()

ReverseComparator

public ReverseComparator(Comparator comparator)
Creates a reverse comparator that inverts the comparison of the passed in comparator. If you pass in a null, the ReverseComparator defaults to reversing the natural order, as per java.util.Collections.reverseOrder().

Parameters:
comparator - Comparator to reverse
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Specified by:
compare in interface Comparator


Copyright © 2001-2002 Apache Software Foundation. Documenation generated February 22 2003.