public final class ValueWrapper
extends java.lang.Object
implements java.io.Serializable
This class only stores the value if it implements Serializable
.
In any case, it stores its runtime type, identity hash code and string
representation, i.e. the result of invoking Object.toString()
.
The toString()
method returns the string representation of the
value along with its type and identity hash code.
System.identityHashCode(java.lang.Object)
,
Serialized FormModifier and Type | Field and Description |
---|---|
private int |
identityHashCode |
private static ValueWrapper |
nullValueWrapper |
private static long |
serialVersionUID |
private java.lang.String |
stringRepresentation |
private java.lang.Class<?> |
type |
private java.io.Serializable |
value |
Modifier | Constructor and Description |
---|---|
private |
ValueWrapper(java.lang.Object value)
Reads and stores the supplied value's runtime type, string representation, and
identity hash code.
|
Modifier and Type | Method and Description |
---|---|
static ValueWrapper |
create(java.lang.Object value)
Factory for creating a new
ValueWrapper for the supplied value . |
int |
getIdentityHashCode()
Returns the value's identity hash code, i.e.
|
java.lang.String |
getStringRepresentation()
Returns the value's string representation, i.e.
|
java.lang.Class<?> |
getType()
Returns the value's runtime type in case it wasn't
null ;
otherwise, null . |
java.io.Serializable |
getValue()
Returns the value as passed to the constructor in case it implemented
Serializable ; otherwise, null . |
java.lang.String |
toString()
Returns the value's string representation along with its type and
identity hash code.
|
private static final long serialVersionUID
private static final ValueWrapper nullValueWrapper
private final java.io.Serializable value
private final java.lang.Class<?> type
private final java.lang.String stringRepresentation
private final int identityHashCode
private ValueWrapper(java.lang.Object value)
public static ValueWrapper create(java.lang.Object value)
ValueWrapper
for the supplied value
.
If the supplied value
is null
, this method will return a
cached ValueWrapper
suitable for all null values.
value
- the value to wrappublic java.io.Serializable getValue()
Serializable
; otherwise, null
.public java.lang.Class<?> getType()
null
;
otherwise, null
.public java.lang.String getStringRepresentation()
Object.toString()
at the time this object's constructor was
called. Returns "null"
if the value was null
.public int getIdentityHashCode()
System.identityHashCode(java.lang.Object)
at the time this object's constructor
was called. Returns 0
if the value was null
.public java.lang.String toString()
toString
in class java.lang.Object