jdsl.core.ref
Class ComparatorExtender
java.lang.Object
jdsl.core.ref.AbstractComparator
jdsl.core.ref.ComparatorExtender
- All Implemented Interfaces:
- Comparator, EqualityComparator
- public class ComparatorExtender
- extends AbstractComparator
- implements Comparator
Takes a java.util.Comparator and adapts it to the
jdsl.core.api.Comparator.
- Version:
- JDSL 2.1.1
- Author:
- Mike Boilen (mgb), Luca Vismara (lv)
|
Method Summary |
int |
compare(Object x1,
Object x2)
Adapts the comparator method of the underlying comparator. |
boolean |
isComparable(Object o)
Tests if an object is comparator by asking the comparator if
compare(o,o) |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ComparatorExtender
public ComparatorExtender(Comparator comparator)
- Constructs a new comparator which adapts the given
java.util.Comparator.
compare
public int compare(Object x1,
Object x2)
throws ClassCastException
- Adapts the comparator method of the underlying comparator.
- Specified by:
compare in interface Comparator- Specified by:
compare in class AbstractComparator
- Returns:
- a negative value if a < b, zero if a == b, and a positive
value if a > b
- Throws:
ClassCastException - if the underlying comparator throws a
ClassCastException- See Also:
Comparator.compare(Object,Object)
isComparable
public boolean isComparable(Object o)
- Tests if an object is comparator by asking the comparator if
compare(o,o)
- Specified by:
isComparable in interface EqualityComparator
- Parameters:
o - Any java.lang.Object
- Returns:
- True if and only if this comparator may compare this object.
- See Also:
Comparator.compare(Object,Object)