|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.aavalla.utils.general.UniqueComparable<T>
public final class UniqueComparable<T extends java.lang.Comparable>
Wrapper for an object 'value' implementing Comparable interface. UniqueComparable's compareTo() returns the result of the underlying value object's compareTo() except if it would return 0. In that case UniqueComparable's compareTo() compares the age of the objects. The only time UniqueComparable's compareTo() ever returns 0, is if the UniqueComparable objects are actually the same object. The idea is that values can be ordered and kept unique. This way, for example, an OrderedSet can hold objects with equal values while keeping consistent with equals(). Immutable. Thread-safe.
Constructor Summary | |
---|---|
UniqueComparable(T value)
Constructor |
Method Summary | |
---|---|
int |
compareTo(UniqueComparable<T> o)
|
T |
value()
Returns the value held. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UniqueComparable(T value)
value
- value to hold
java.lang.NullPointerException
- Thrown, if trying to add null valueMethod Detail |
---|
public final T value()
public final int compareTo(UniqueComparable<T> o)
compareTo
in interface java.lang.Comparable<UniqueComparable<T extends java.lang.Comparable>>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |