public abstract class NamedInteger extends Number implements DataObject, Immutable
public static T fromValue(int value)
public static T[] namedValues()
public static int MIN_VALUE
public static int MAX_VALUE
Modifier | Constructor and Description |
---|---|
protected |
NamedInteger(long value)
Constructs an integer without an associated name.
|
protected |
NamedInteger(long value,
String description)
Constructs an integer with an associated name.
|
Modifier and Type | Method and Description |
---|---|
byte |
byteValue()
Returns the value of this number as a byte.
|
Object |
clone()
Perform a deep copy of this object.
|
double |
doubleValue()
Returns the value of this number as a double.
|
boolean |
equals(Object obj)
Compares some other object to this one for equality by value (not reference).
|
float |
floatValue()
Returns the value of this number as a float.
|
int |
hashCode()
Gets a hash code value for this object.
|
int |
intValue()
Returns the value of this number as an int.
|
boolean |
isReadOnly()
Check if this object has been set read-only.
|
long |
longValue()
Returns the value of this number as a long.
|
void |
setReadOnly()
Set this object to be "read-only".
|
short |
shortValue()
Returns the value of this number as a short.
|
String |
toString()
Returns either the name of this number if it has a name,
or a string formed from the decimal digits of the number.
|
static <T extends NamedInteger> |
valueOf(Class<T> namedIntegerType,
String name)
Gets the NamedInteger of the given type that has the given name.
|
protected NamedInteger(long value, String description)
value
- integerdescription
- nameprotected NamedInteger(long value)
value
- integerpublic Object clone()
DataObject
Inherently immutable objects may optionally return the same object without modification from clone(), rather than constructing a new instance.
clone
in interface DataObject
clone
in class Object
public void setReadOnly()
DataObject
Note that a read-only object is not necessarily immutable; if reference types are returned from accessors, then callers could theoretically mutate those objects even if the top-level object is marked as read-only. The ability to make objects read-only is intended to catch programming errors (e.g. attempting to modify a data object passed as part of a SLEE event), not to provide an absolute guarantee of immutability.
Calling setReadOnly() on an object that is already read-only is a no-op.
Some DataObject implementations may be inherently immutable. In those cases, they are considered always read-only.
setReadOnly
in interface DataObject
public boolean isReadOnly()
DataObject
isReadOnly
in interface DataObject
DataObject.setReadOnly()
public byte byteValue()
public double doubleValue()
doubleValue
in class Number
public float floatValue()
floatValue
in class Number
public int intValue()
public long longValue()
public short shortValue()
shortValue
in class Number
public String toString()
public boolean equals(Object obj)
public int hashCode()
public static <T extends NamedInteger> T valueOf(Class<T> namedIntegerType, String name)
namedIntegerType
- the class of the resultname
- the name of the resultIllegalArgumentException
- if name isn't foundNullPointerException
- if namedIntegerType or name is null