public class PdxInstanceWrapper
extends java.lang.Object
implements org.apache.geode.pdx.PdxInstance, org.apache.geode.internal.Sendable
PdxInstanceWrapper class is an implementation of the PdxInstance interface
wrapping an existing PdxInstance object and decorating the functionality.Function,
ObjectMapper,
JSONFormatter,
PdxInstance,
WritablePdxInstance,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
ARRAY_BEGIN |
protected static java.lang.String |
ARRAY_END |
static java.lang.String |
AT_IDENTIFIER_FIELD_NAME |
static java.lang.String |
AT_TYPE_FIELD_NAME |
static java.lang.String |
CLASS_NAME_PROPERTY |
protected static java.lang.String |
COMMA |
protected static java.lang.String |
COMMA_NEW_LINE |
protected static java.lang.String |
COMMA_SPACE |
protected static java.lang.String |
EMPTY_STRING |
protected static java.lang.String |
FIELD_TYPE_VALUE |
static java.lang.String |
ID_FIELD_NAME |
protected static java.lang.String |
INDENT_STRING |
protected static java.lang.String |
NEW_LINE |
protected static java.lang.String |
NO_FIELD_NAME |
protected static java.lang.String |
OBJECT_BEGIN |
protected static java.lang.String |
OBJECT_END |
| Constructor and Description |
|---|
PdxInstanceWrapper(org.apache.geode.pdx.PdxInstance pdxInstance)
Constructs a new instance of
PdxInstanceWrapper initialized with the given, required PdxInstance
object used to back this wrapper. |
| Modifier and Type | Method and Description |
|---|---|
org.apache.geode.pdx.WritablePdxInstance |
createWriter() |
static java.lang.Object |
from(java.lang.Object target)
Smart, null-safe factory method used to evaluate the given
Object and wrap the Object
in a new instance of PdxInstanceWrapper if the Object is an instance of PdxInstance
or return the given Object as is. |
static PdxInstanceWrapper |
from(org.apache.geode.pdx.PdxInstance pdxInstance)
Factory method used to construct a new instance of
PdxInstanceWrapper initialized with the given,
required PdxInstance used to back the wrapper. |
protected java.lang.Object |
getAtIdentifier()
Searches for a PDX
field declared by the @identifier metadata field
on this PdxInstance and returns the value of this field
as the identifier for, or identity of,
this PdxInstance. |
java.lang.String |
getClassName() |
org.apache.geode.pdx.PdxInstance |
getDelegate()
Returns a reference to the configured, underlying
PdxInstance backing this wrapper. |
java.lang.Object |
getField(java.lang.String fieldName) |
java.util.List<java.lang.String> |
getFieldNames() |
protected java.lang.Object |
getId()
Searches for a PDX
field name called id on this PdxInstance
and returns its value as the identifier for,
or identity of, this PdxInstance. |
java.lang.Object |
getIdentifier()
Determines the
identifier for, or identity of,
this PdxInstance. |
java.lang.Object |
getObject()
Materializes an
Object from the PDX bytes described by this PdxInstance. |
protected java.util.Optional<com.fasterxml.jackson.databind.ObjectMapper> |
getObjectMapper()
Returns an
Optional reference to a configured Jackson ObjectMapper used to
deserialize the JSON generated from PDX back into an Object. |
boolean |
hasField(java.lang.String fieldName) |
boolean |
isDeserializable() |
boolean |
isEnum() |
boolean |
isIdentityField(java.lang.String fieldName) |
void |
sendTo(java.io.DataOutput out) |
java.lang.String |
toString()
Returns a
String representation of this PdxInstance. |
static org.apache.geode.pdx.PdxInstance |
unwrap(org.apache.geode.pdx.PdxInstance pdxInstance)
Null-safe factory method used to unwrap the given
PdxInstance. |
public static final java.lang.String AT_IDENTIFIER_FIELD_NAME
public static final java.lang.String AT_TYPE_FIELD_NAME
public static final java.lang.String CLASS_NAME_PROPERTY
public static final java.lang.String ID_FIELD_NAME
protected static final java.lang.String NO_FIELD_NAME
protected static final java.lang.String ARRAY_BEGIN
protected static final java.lang.String ARRAY_END
protected static final java.lang.String COMMA
protected static final java.lang.String EMPTY_STRING
protected static final java.lang.String FIELD_TYPE_VALUE
protected static final java.lang.String INDENT_STRING
protected static final java.lang.String NEW_LINE
protected static final java.lang.String COMMA_NEW_LINE
protected static final java.lang.String COMMA_SPACE
protected static final java.lang.String OBJECT_BEGIN
protected static final java.lang.String OBJECT_END
public PdxInstanceWrapper(org.apache.geode.pdx.PdxInstance pdxInstance)
PdxInstanceWrapper initialized with the given, required PdxInstance
object used to back this wrapper.pdxInstance - PdxInstance object used to back this wrapper; must not be null.java.lang.IllegalArgumentException - if PdxInstance is null.PdxInstancepublic static java.lang.Object from(java.lang.Object target)
Object and wrap the Object
in a new instance of PdxInstanceWrapper if the Object is an instance of PdxInstance
or return the given Object as is.target - Object to evaluateObject wrapped in a new instance of PdxInstanceWrapper if Object
is an instance of PdxInstance, otherwise returns the given Object.PdxInstance,
Object,
from(PdxInstance)public static PdxInstanceWrapper from(org.apache.geode.pdx.PdxInstance pdxInstance)
PdxInstanceWrapper initialized with the given,
required PdxInstance used to back the wrapper.pdxInstance - PdxInstance object used to back this wrapper; must not be null.PdxInstanceWrapper initialized with the given PdxInstance.java.lang.IllegalArgumentException - if PdxInstance is null.PdxInstance,
PdxInstanceWrapper(PdxInstance)public static org.apache.geode.pdx.PdxInstance unwrap(org.apache.geode.pdx.PdxInstance pdxInstance)
PdxInstance.
If the given PdxInstance is an instance of PdxInstanceWrapper then this factory method will
unwrap the PdxInstanceWrapper returning the underlying, delegate
PdxInstance. Otherwise, the given PdxInstance is returned.pdxInstance - PdxInstance to unwrap; may be null.PdxInstance.PdxInstance,
getDelegate()public org.apache.geode.pdx.PdxInstance getDelegate()
PdxInstance backing this wrapper.PdxInstance backing this wrapper;
never null.PdxInstanceprotected java.util.Optional<com.fasterxml.jackson.databind.ObjectMapper> getObjectMapper()
Optional reference to a configured Jackson ObjectMapper used to
deserialize the JSON generated from PDX back into an Object.
This method is meant ot be overridden by subclasses.Optional ObjectMapper.ObjectMapper,
Optionalpublic java.lang.String getClassName()
getClassName in interface org.apache.geode.pdx.PdxInstancepublic boolean isDeserializable()
isDeserializable in interface org.apache.geode.pdx.PdxInstancepublic boolean isEnum()
isEnum in interface org.apache.geode.pdx.PdxInstancepublic java.lang.Object getField(java.lang.String fieldName)
getField in interface org.apache.geode.pdx.PdxInstancepublic java.util.List<java.lang.String> getFieldNames()
getFieldNames in interface org.apache.geode.pdx.PdxInstancepublic java.lang.Object getIdentifier()
identifier for, or identity of,
this PdxInstance.identifier for this PdxInstance; never null.java.lang.IllegalStateException - if the PdxInstance does not have an id.isIdentityField(String),
getField(String),
getFieldNames(),
getId()protected java.lang.Object getId()
field name called id on this PdxInstance
and returns its value as the identifier for,
or identity of, this PdxInstance.value of the id field on this PdxInstance.java.lang.IllegalStateException - if this PdxInstance does not have an id.getAtIdentifier(),
getField(String),
hasField(String)protected java.lang.Object getAtIdentifier()
field declared by the @identifier metadata field
on this PdxInstance and returns the value of this field
as the identifier for, or identity of,
this PdxInstance.value of the field declared in the @identifier metadata
field on this PdxInstance.java.lang.IllegalStateException - if the PdxInstance does not have an id.PdxInstancepublic boolean isIdentityField(java.lang.String fieldName)
isIdentityField in interface org.apache.geode.pdx.PdxInstancepublic java.lang.Object getObject()
Object from the PDX bytes described by this PdxInstance.
If these PDX bytes describe an Object parsed from JSON, then the JSON is reconstructed from
this PdxInstance and mapped to an instance of the type identified by
the @type metadata PDX field using Jackson's ObjectMapper.getObject in interface org.apache.geode.pdx.PdxInstanceObject constructed from the PDX bytes described by this PdxInstance.ObjectMapper,
Object,
getObjectMapper()public org.apache.geode.pdx.WritablePdxInstance createWriter()
createWriter in interface org.apache.geode.pdx.PdxInstancepublic boolean hasField(java.lang.String fieldName)
hasField in interface org.apache.geode.pdx.PdxInstancepublic void sendTo(java.io.DataOutput out)
throws java.io.IOException
sendTo in interface org.apache.geode.internal.Sendablejava.io.IOExceptionpublic java.lang.String toString()
String representation of this PdxInstance.toString in interface org.apache.geode.pdx.PdxInstancetoString in class java.lang.ObjectString representation of this PdxInstance.String