Package org.springframework.geode.pdx
Class PdxInstanceWrapper
java.lang.Object
org.springframework.geode.pdx.PdxInstanceWrapper
- All Implemented Interfaces:
Serializable
,org.apache.geode.cache.Document
,org.apache.geode.internal.Sendable
,org.apache.geode.pdx.PdxInstance
public class PdxInstanceWrapper
extends Object
implements org.apache.geode.pdx.PdxInstance, org.apache.geode.internal.Sendable
The
PdxInstanceWrapper
class is an implementation of the PdxInstance
interface
wrapping an existing PdxInstance
object and decorating the functionality.- Since:
- 1.3.0
- See Also:
-
Function
ObjectMapper
JSONFormatter
PdxInstance
WritablePdxInstance
- Serialized Form
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
static final String
static final String
static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
static final String
protected static final String
protected static final String
protected static final String
protected static final String
protected static final String
Fields inherited from interface org.apache.geode.cache.Document
FIELD_NOT_FOUND
-
Constructor Summary
ConstructorDescriptionPdxInstanceWrapper
(org.apache.geode.pdx.PdxInstance pdxInstance) Constructs a new instance ofPdxInstanceWrapper
initialized with the given, requiredPdxInstance
object used to back this wrapper. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.geode.pdx.WritablePdxInstance
static Object
Smart, null-safe factory method used to evaluate the givenObject
and wrap theObject
in a new instance ofPdxInstanceWrapper
if theObject
is an instance ofPdxInstance
or return the givenObject
as is.static PdxInstanceWrapper
from
(org.apache.geode.pdx.PdxInstance pdxInstance) Factory method used to construct a new instance ofPdxInstanceWrapper
initialized with the given, requiredPdxInstance
used to back the wrapper.protected Object
Searches for a PDXfield
declared by the @identifier metadatafield
on thisPdxInstance
and returns thevalue
of thisfield
as theidentifier
for, oridentity
of, thisPdxInstance
.org.apache.geode.pdx.PdxInstance
Returns a reference to the configured, underlyingPdxInstance
backing this wrapper.protected Object
getId()
Searches for a PDXfield name
called id on thisPdxInstance
and returns itsvalue
as theidentifier
for, oridentity
of, thisPdxInstance
.Materializes anObject
from the PDX bytes described by thisPdxInstance
.protected Optional<com.fasterxml.jackson.databind.ObjectMapper>
boolean
boolean
boolean
isEnum()
boolean
isIdentityField
(String fieldName) void
sendTo
(DataOutput out) toString()
Returns aString
representation of thisPdxInstance
.static org.apache.geode.pdx.PdxInstance
unwrap
(org.apache.geode.pdx.PdxInstance pdxInstance) Null-safe factory method used to unwrap the givenPdxInstance
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.geode.cache.Document
foreach, getAndCheckField
Methods inherited from interface org.apache.geode.pdx.PdxInstance
equals, hashCode
-
Field Details
-
AT_IDENTIFIER_FIELD_NAME
- See Also:
-
AT_TYPE_FIELD_NAME
- See Also:
-
CLASS_NAME_PROPERTY
- See Also:
-
ID_FIELD_NAME
- See Also:
-
NO_FIELD_NAME
- See Also:
-
ARRAY_BEGIN
- See Also:
-
ARRAY_END
- See Also:
-
COMMA
- See Also:
-
EMPTY_STRING
- See Also:
-
FIELD_TYPE_VALUE
- See Also:
-
INDENT_STRING
- See Also:
-
NEW_LINE
- See Also:
-
COMMA_NEW_LINE
- See Also:
-
COMMA_SPACE
- See Also:
-
OBJECT_BEGIN
- See Also:
-
OBJECT_END
- See Also:
-
-
Constructor Details
-
PdxInstanceWrapper
public PdxInstanceWrapper(org.apache.geode.pdx.PdxInstance pdxInstance) Constructs a new instance ofPdxInstanceWrapper
initialized with the given, requiredPdxInstance
object used to back this wrapper.- Parameters:
pdxInstance
-PdxInstance
object used to back this wrapper; must not be null.- Throws:
IllegalArgumentException
- ifPdxInstance
is null.- See Also:
-
PdxInstance
-
-
Method Details
-
from
Smart, null-safe factory method used to evaluate the givenObject
and wrap theObject
in a new instance ofPdxInstanceWrapper
if theObject
is an instance ofPdxInstance
or return the givenObject
as is.- Parameters:
target
-Object
to evaluate- Returns:
- the
Object
wrapped in a new instance ofPdxInstanceWrapper
ifObject
is an instance ofPdxInstance
, otherwise returns the givenObject
. - See Also:
-
PdxInstance
Object
from(PdxInstance)
-
from
Factory method used to construct a new instance ofPdxInstanceWrapper
initialized with the given, requiredPdxInstance
used to back the wrapper.- Parameters:
pdxInstance
-PdxInstance
object used to back this wrapper; must not be null.- Returns:
- a new instance of
PdxInstanceWrapper
initialized with the givenPdxInstance
. - Throws:
IllegalArgumentException
- ifPdxInstance
is null.- See Also:
-
PdxInstance
PdxInstanceWrapper(PdxInstance)
-
unwrap
public static org.apache.geode.pdx.PdxInstance unwrap(org.apache.geode.pdx.PdxInstance pdxInstance) Null-safe factory method used to unwrap the givenPdxInstance
. If the givenPdxInstance
is an instance ofPdxInstanceWrapper
then this factory method will unwrap thePdxInstanceWrapper
returning the underlying,delegate
PdxInstance
. Otherwise, the givenPdxInstance
is returned.- Parameters:
pdxInstance
-PdxInstance
to unwrap; may be null.- Returns:
- the unwrapped
PdxInstance
. - See Also:
-
PdxInstance
getDelegate()
-
getDelegate
public org.apache.geode.pdx.PdxInstance getDelegate()Returns a reference to the configured, underlyingPdxInstance
backing this wrapper.- Returns:
- a reference to the configured, underlying
PdxInstance
backing this wrapper; never null. - See Also:
-
PdxInstance
-
getObjectMapper
Returns anOptional
reference to a configured JacksonObjectMapper
used to deserialize theJSON
generated fromPDX
back into anObject
. This method is meant ot be overridden bysubclasses
. -
getClassName
- Specified by:
getClassName
in interfaceorg.apache.geode.pdx.PdxInstance
-
isDeserializable
public boolean isDeserializable()- Specified by:
isDeserializable
in interfaceorg.apache.geode.pdx.PdxInstance
-
isEnum
public boolean isEnum()- Specified by:
isEnum
in interfaceorg.apache.geode.pdx.PdxInstance
-
getField
- Specified by:
getField
in interfaceorg.apache.geode.cache.Document
- Specified by:
getField
in interfaceorg.apache.geode.pdx.PdxInstance
-
getFieldNames
- Specified by:
getFieldNames
in interfaceorg.apache.geode.cache.Document
-
getIdentifier
- Returns:
- the
identifier
for thisPdxInstance
; never null. - Throws:
IllegalStateException
- if thePdxInstance
does not have an id.- See Also:
-
getId
Searches for a PDXfield name
called id on thisPdxInstance
and returns itsvalue
as theidentifier
for, oridentity
of, thisPdxInstance
.- Returns:
- the
value
of the idfield
on thisPdxInstance
. - Throws:
IllegalStateException
- if thisPdxInstance
does not have an id.- See Also:
-
getAtIdentifier
Searches for a PDXfield
declared by the @identifier metadatafield
on thisPdxInstance
and returns thevalue
of thisfield
as theidentifier
for, oridentity
of, thisPdxInstance
.- Returns:
- the
value
of thefield
declared in the @identifier metadatafield
on thisPdxInstance
. - Throws:
IllegalStateException
- if thePdxInstance
does not have an id.- See Also:
-
PdxInstance
-
isIdentityField
- Specified by:
isIdentityField
in interfaceorg.apache.geode.pdx.PdxInstance
-
getObject
Materializes anObject
from the PDX bytes described by thisPdxInstance
. If these PDX bytes describe anObject
parsed from JSON, then the JSON is reconstructed from thisPdxInstance
and mapped to an instance of thetype
identified by the @type metadata PDXfield
using Jackson'sObjectMapper
.- Specified by:
getObject
in interfaceorg.apache.geode.pdx.PdxInstance
- Returns:
- an
Object
constructed from the PDX bytes described by thisPdxInstance
. - See Also:
-
ObjectMapper
Object
getObjectMapper()
-
createWriter
public org.apache.geode.pdx.WritablePdxInstance createWriter()- Specified by:
createWriter
in interfaceorg.apache.geode.pdx.PdxInstance
-
hasField
- Specified by:
hasField
in interfaceorg.apache.geode.cache.Document
-
sendTo
- Specified by:
sendTo
in interfaceorg.apache.geode.internal.Sendable
- Throws:
IOException
-
toString
Returns aString
representation of thisPdxInstance
.
-