jdsl.core.api
Interface Comparator

All Known Implementing Classes:
StringComparator, IntegerComparator

public abstract interface Comparator

A comparator does comparisons of objects in the universe the comparator is defined over. A comparator throws an InvalidElementException if passed a null element, or an element outside of its universe.

Author:
Mark Handy

Method Summary
 boolean isComparable(java.lang.Object a)
          Tests whether this comparator can compare this object
 boolean isEqualTo(java.lang.Object a, java.lang.Object b)
          Tests equality of two objects in the universe over which this comparator is defined.
 boolean isGreaterThan(java.lang.Object a, java.lang.Object b)
          Tests strict order of two objects in the universe 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 strict order of two objects in the universe 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.
 

Method Detail

isEqualTo

public boolean isEqualTo(java.lang.Object a,
                         java.lang.Object b)
                  throws InvalidElementException
Tests equality of two objects in the universe over which this comparator is defined.
Parameters:
a -  
b -  
Returns:
whether a is equal to b

isGreaterThan

public boolean isGreaterThan(java.lang.Object a,
                             java.lang.Object b)
                      throws InvalidElementException
Tests strict order of two objects in the universe over which this comparator is defined.
Parameters:
a -  
b -  
Returns:
whether a is greater than b

isLessThan

public boolean isLessThan(java.lang.Object a,
                          java.lang.Object b)
                   throws InvalidElementException
Tests strict order of two objects in the universe over which this comparator is defined.
Parameters:
a -  
b -  
Returns:
whether a is less than b

isGreaterThanOrEqualTo

public boolean isGreaterThanOrEqualTo(java.lang.Object a,
                                      java.lang.Object b)
                               throws InvalidElementException
Tests non-strict order of two objects in the universe over which this comparator is defined.
Parameters:
a -  
b -  
Returns:
whether a is greater than or equal to b

isLessThanOrEqualTo

public boolean isLessThanOrEqualTo(java.lang.Object a,
                                   java.lang.Object b)
                            throws InvalidElementException
Tests non-strict order of two objects in the universe over which this comparator is defined.
Parameters:
a -  
b -  
Returns:
whether a is less than or equal to b

isComparable

public boolean isComparable(java.lang.Object a)
Tests whether this comparator can compare this object
Parameters:
a -  
Returns:
whether a can be compared to other objects using this comparator