com.jalios.util
Class ReverseComparator<T>

java.lang.Object
  extended by com.jalios.util.ReverseComparator<T>
All Implemented Interfaces:
Comparator<T>

public class ReverseComparator<T>
extends Object
implements Comparator<T>

This class is comparator which reverse the ordering of a given comparator.

Version:
$Revision: 21407 $
Author:
Olivier Dedieu

Field Summary
protected  Comparator<T> comparator
           
static String REVISION
           
 
Constructor Summary
ReverseComparator()
          Defaut constructor reverse NaturalComparator Objects mus be Comparable
ReverseComparator(Comparator<T> comparator)
          This constructor will reverse returned value by given comparator.
 
Method Summary
 int compare(T o1, T o2)
           
 Comparator<T> getReversedComparator()
          Retrieve the Comparator this ReverseComparator is reversing or null when the natural Comparator is reversed.
 
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
 

Field Detail

REVISION

public static final String REVISION
See Also:
Constant Field Values

comparator

protected Comparator<T> comparator
Constructor Detail

ReverseComparator

public ReverseComparator()
Defaut constructor reverse NaturalComparator Objects mus be Comparable


ReverseComparator

public ReverseComparator(Comparator<T> comparator)
This constructor will reverse returned value by given comparator.

Parameters:
comparator - used to compare object
Method Detail

getReversedComparator

public Comparator<T> getReversedComparator()
Retrieve the Comparator this ReverseComparator is reversing or null when the natural Comparator is reversed.

Returns:
the Comparator instance being used or null if we are reversing the natural Comparator of the objects.

compare

public int compare(T o1,
                   T o2)
Specified by:
compare in interface Comparator<T>


Copyright © 2001-2010 Jalios SA. All Rights Reserved.