|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.collections15.comparators.ComparableComparator<E>
public class ComparableComparator<E extends java.lang.Comparable>
A Comparator
that compares Comparable
objects.
SortedSet
and SortedMap
.
Collections.reverseOrder()
,
Serialized FormConstructor Summary | |
---|---|
protected |
ComparableComparator()
Constructs a new instance. |
Method Summary | ||
---|---|---|
int |
compare(E obj1,
E obj2)
Compare the two Comparable arguments. |
|
boolean |
equals(java.lang.Object object)
Determines whether or not a specified object is equal to this ComparableComparator instance. |
|
static
|
getInstance()
Gets a ComparableComparator instance. |
|
int |
hashCode()
Implement a hash code for this comparator that is consistent with equals . |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ComparableComparator()
getInstance()
method.
Method Detail |
---|
public static <T extends java.lang.Comparable> ComparableComparator<T> getInstance()
ComparableComparator
apropriate to the generic
type.public int compare(E obj1, E obj2)
Comparable
arguments. This method is equivalent
to: ((Comparable)obj1).compareTo(obj2)
compare
in interface java.util.Comparator<E extends java.lang.Comparable>
obj1
- The first object to compare.obj2
- The second object to compare.
obj1
is less than
obj2, a positive value if obj1
is
greater than obj2
or zero if obj1
and
obj2
are equal.
java.lang.NullPointerException
- Thrown if obj1
is
null
, or when ((Comparable)obj1).compareTo(obj2)
throws a NullPointerException
.public int hashCode()
equals
.
hashCode
in class java.lang.Object
public boolean equals(java.lang.Object object)
ComparableComparator
instance.
This implementation returns true
only if
object.getClass()
equals
this.getClass()
. Subclasses may want to override this
behavior to remain consistent with the Comparator.equals(Object)
contract.
equals
in interface java.util.Comparator<E extends java.lang.Comparable>
equals
in class java.lang.Object
object
- The object to compare to.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |