
D - Class self reference for Comparable restrictionpublic abstract class ConstantObject<D extends ConstantObject<D>> extends Object implements Comparable<D>
| Modifier and Type | Field and Description |
|---|---|
private static Map<Class<?>,Map<String,ConstantObject<?>>> |
CONSTANT_OBJECTS_INDEX
Index of constant objects.
|
private int |
hashCode
The cached hash code of this object.
|
private String |
name
Holds the value of the property's name.
|
| Modifier | Constructor and Description |
|---|---|
protected |
ConstantObject(String name)
Provides a ConstantObject of the given name.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(D o)
Two constant objects are generally compared by their name.
|
boolean |
equals(Object o) |
String |
getName()
Returns the name of the ConstantObject.
|
int |
hashCode() |
static <D extends ConstantObject<D>> |
lookup(Class<D> type,
String name)
Provides a ConstantObject of specified class and name if it exists.
|
protected Object |
readResolve()
Method for use by the serialization mechanism to ensure identity of
ConstantObjects.
|
private static final Map<Class<?>,Map<String,ConstantObject<?>>> CONSTANT_OBJECTS_INDEX
private final String name
private final int hashCode
protected ConstantObject(String name)
name - name of the ConstantObjectpublic String getName()
public static final <D extends ConstantObject<D>> D lookup(Class<D> type, String name)
D - Type for compile time type checkingtype - the type of the desired ConstantObjectname - the name of the desired ConstantObjectprotected Object readResolve()
public boolean equals(Object o)
equals in class ObjectObject.equals(Object)public int hashCode()
hashCode in class ObjectObject.hashCode()public int compareTo(D o)
this.getName().compareTo(o.getName().compareTo in interface Comparable<D extends ConstantObject<D>>o - Object to compare to.Comparable.compareTo(java.lang.Object)