org.apache.commons.collections.comparators

Class ReverseComparator

Implemented Interfaces:
Comparator, Serializable

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

Reverses the order of another comparator.
Version:
$Id: ReverseComparator.java,v 1.8.2.1 2004/05/22 12:14:04 scolebourne Exp $
Authors:
bayard@generationjava.com
Michael A. Smith
Since:
2.0

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)

Constructor Details

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:
java.util.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 Details

compare

public int compare(Object o1,
                   Object o2)

Copyright © 2001-2004 Apache Software Foundation. Documenation generated ${TODAY}.