jdsl.core.ref
Class ComparatorReverser

java.lang.Object
  |
  +--jdsl.core.ref.ComparatorReverser
All Implemented Interfaces:
Comparator, EqualityComparator

public class ComparatorReverser
extends java.lang.Object
implements Comparator

Takes a Comparator and reverses the ordering with respect to which the elements are compared.

Version:
JDSL 2.0.6
Author:
Don Blaheta (dpb), Luca Vismara (lv)

Constructor Summary
ComparatorReverser(Comparator cmp)
           
 
Method Summary
 int compare(java.lang.Object a, java.lang.Object b)
          A C-style comparison function that returns a negative value if the first object is less than the second, a positive value if the second object is less, and 0 if the two objects are equal.
 boolean isComparable(java.lang.Object obj)
          Allows a container (or any client) to find out whether an object is a member of the ordered set over which this comparator is defined.
 boolean isEqualTo(java.lang.Object a, java.lang.Object b)
          Tests the two parameter objects in the set over which the comparator is defined for equality.
 boolean isGreaterThan(java.lang.Object a, java.lang.Object b)
          Tests the strict order of two objects in the set over which this comparator is defined.
 boolean isGreaterThanOrEqualTo(java.lang.Object a, java.lang.Object b)
          Tests non-strict order of two objects in the universe over which this comparator is defined.
 boolean isLessThan(java.lang.Object a, java.lang.Object b)
          Tests the strict order of two objects in the set over which this comparator is defined.
 boolean isLessThanOrEqualTo(java.lang.Object a, java.lang.Object b)
          Tests non-strict order of two objects in the universe over which this comparator is defined.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComparatorReverser

public ComparatorReverser(Comparator cmp)
Parameters:
c - The comparator to be reversed.
Method Detail

compare

public int compare(java.lang.Object a,
                   java.lang.Object b)
Description copied from interface: Comparator
A C-style comparison function that returns a negative value if the first object is less than the second, a positive value if the second object is less, and 0 if the two objects are equal.
Specified by:
compare in interface Comparator
Returns:
the negation of a compare(Object,Object) call to the slave comparator; so if the other comparator guarantees some number with an absolute value greater than one, that value will be preserved

isComparable

public boolean isComparable(java.lang.Object obj)
Description copied from interface: EqualityComparator
Allows a container (or any client) to find out whether an object is a member of the ordered set over which this comparator is defined.
Specified by:
isComparable in interface EqualityComparator
Following copied from interface: jdsl.core.api.EqualityComparator
Parameters:
o - Any java.lang.Object
Returns:
True if and only if this comparator may compare this object.

isEqualTo

public boolean isEqualTo(java.lang.Object a,
                         java.lang.Object b)
Description copied from interface: EqualityComparator
Tests the two parameter objects in the set over which the comparator is defined for equality.
Specified by:
isEqualTo in interface EqualityComparator
Following copied from interface: jdsl.core.api.EqualityComparator
Parameters:
a - First Object to compare
b - Second Object to compare
Returns:
True if and only if a is equal to b
Throws:
java.lang.ClassCastException - If either object passed in as a parameter is not a member of the set over which the comparator is defined.

isGreaterThan

public boolean isGreaterThan(java.lang.Object a,
                             java.lang.Object b)
Description copied from interface: Comparator
Tests the strict order of two objects in the set over which this comparator is defined.
Specified by:
isGreaterThan in interface Comparator
Following copied from interface: jdsl.core.api.Comparator
Parameters:
a - First Object to compare
b - Second Object to compare
Returns:
True if and only if a is greater than b
Throws:
java.lang.ClassCastException - If either object passed in as a parameter is not a member of the set over which the comparator is defined.

isGreaterThanOrEqualTo

public boolean isGreaterThanOrEqualTo(java.lang.Object a,
                                      java.lang.Object b)
Description copied from interface: Comparator
Tests non-strict order of two objects in the universe over which this comparator is defined.
Specified by:
isGreaterThanOrEqualTo in interface Comparator
Following copied from interface: jdsl.core.api.Comparator
Parameters:
a - First Object to compare
b - Second Object to compare
Returns:
True if a is greater b or if a is equal to b
Throws:
java.lang.ClassCastException - If either object passed in as a parameter is not a member of the set over which the comparator is defined.

isLessThan

public boolean isLessThan(java.lang.Object a,
                          java.lang.Object b)
Description copied from interface: Comparator
Tests the strict order of two objects in the set over which this comparator is defined.
Specified by:
isLessThan in interface Comparator
Following copied from interface: jdsl.core.api.Comparator
Parameters:
a - First Object to compare
b - Second Object to compare
Returns:
True if and only if a is less than b
Throws:
java.lang.ClassCastException - If either object passed in as a parameter is not a member of the set over which the comparator is defined.

isLessThanOrEqualTo

public boolean isLessThanOrEqualTo(java.lang.Object a,
                                   java.lang.Object b)
Description copied from interface: Comparator
Tests non-strict order of two objects in the universe over which this comparator is defined.
Specified by:
isLessThanOrEqualTo in interface Comparator
Following copied from interface: jdsl.core.api.Comparator
Parameters:
a - First Object to compare
b - Second Object to compare
Returns:
True if a is less than b or if a is equal to b
Throws:
java.lang.ClassCastException - If either object passed in as a parameter is not a member of the set over which the comparator is defined.