org.apache.commons.collections.comparators
Class ReverseComparator

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

public class ReverseComparator
extends java.lang.Object
implements java.util.Comparator, java.io.Serializable

Reverses the order of another comparator.

Since:
2.0
Version:
$Id: ReverseComparator.java,v 1.8.2.1 2004/05/22 12:14:04 scolebourne 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(java.util.Comparator comparator)
          Creates a reverse comparator that inverts the comparison of the passed in comparator.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
           
 
Methods inherited from class java.lang.Object
equals, 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(java.util.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(java.lang.Object o1,
                   java.lang.Object o2)
Specified by:
compare in interface java.util.Comparator


Copyright © 2001-2004 The Apache Software Foundation. All Rights Reserved.