org.pfsw.text
Class ReverseComparator<T>

java.lang.Object
  extended by org.pfsw.text.ReverseComparator<T>
All Implemented Interfaces:
java.util.Comparator<T>

public class ReverseComparator<T>
extends java.lang.Object
implements java.util.Comparator<T>

Provides a comparator implementation that is a wrapper around another comparator with the purpose to reverse the compare order of the given objects. That allows to easily reverse the sort order of any object collection for which a comparator is available.


Constructor Summary
ReverseComparator(java.util.Comparator<T> aComparator)
          Initialize the new instance with another comparator
 
Method Summary
 int compare(T o1, T o2)
          Compares its two arguments for order.
protected  java.util.Comparator<T> getComparator()
           
protected  void setComparator(java.util.Comparator<T> newValue)
           
 
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(java.util.Comparator<T> aComparator)
Initialize the new instance with another comparator

Method Detail

compare

public int compare(T o1,
                   T o2)
Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is greater than, equal to, or less than the second.

Specified by:
compare in interface java.util.Comparator<T>

getComparator

protected java.util.Comparator<T> getComparator()

setComparator

protected void setComparator(java.util.Comparator<T> newValue)