Package org.springframework.geode.pdx
Class PdxInstanceWrapper
java.lang.Object
org.springframework.geode.pdx.PdxInstanceWrapper
- All Implemented Interfaces:
Serializable,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:
-
FunctionObjectMapperJSONFormatterPdxInstanceWritablePdxInstance- Serialized Form
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringstatic final Stringstatic final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringstatic final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
ConstructorsConstructorDescriptionPdxInstanceWrapper(org.apache.geode.pdx.PdxInstance pdxInstance) Constructs a new instance ofPdxInstanceWrapperinitialized with the given, requiredPdxInstanceobject used to back this wrapper. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.geode.pdx.WritablePdxInstancestatic ObjectSmart, null-safe factory method used to evaluate the givenObjectand wrap theObjectin a new instance ofPdxInstanceWrapperif theObjectis an instance ofPdxInstanceor return the givenObjectas is.static PdxInstanceWrapperfrom(org.apache.geode.pdx.PdxInstance pdxInstance) Factory method used to construct a new instance ofPdxInstanceWrapperinitialized with the given, requiredPdxInstanceused to back the wrapper.protected ObjectSearches for a PDXfielddeclared by the @identifier metadatafieldon thisPdxInstanceand returns thevalueof thisfieldas theidentifierfor, oridentityof, thisPdxInstance.org.apache.geode.pdx.PdxInstanceReturns a reference to the configured, underlyingPdxInstancebacking this wrapper.protected ObjectgetId()Searches for a PDXfield namecalled id on thisPdxInstanceand returns itsvalueas theidentifierfor, oridentityof, thisPdxInstance.Materializes anObjectfrom the PDX bytes described by thisPdxInstance.protected Optional<com.fasterxml.jackson.databind.ObjectMapper>booleanbooleanbooleanisEnum()booleanisIdentityField(String fieldName) voidsendTo(DataOutput out) toString()Returns aStringrepresentation of thisPdxInstance.static org.apache.geode.pdx.PdxInstanceunwrap(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, waitMethods 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 ofPdxInstanceWrapperinitialized with the given, requiredPdxInstanceobject used to back this wrapper.- Parameters:
pdxInstance-PdxInstanceobject used to back this wrapper; must not be null.- Throws:
IllegalArgumentException- ifPdxInstanceis null.- See Also:
-
PdxInstance
-
-
Method Details
-
from
Smart, null-safe factory method used to evaluate the givenObjectand wrap theObjectin a new instance ofPdxInstanceWrapperif theObjectis an instance ofPdxInstanceor return the givenObjectas is.- Parameters:
target-Objectto evaluate- Returns:
- the
Objectwrapped in a new instance ofPdxInstanceWrapperifObjectis an instance ofPdxInstance, otherwise returns the givenObject. - See Also:
-
PdxInstanceObjectfrom(PdxInstance)
-
from
Factory method used to construct a new instance ofPdxInstanceWrapperinitialized with the given, requiredPdxInstanceused to back the wrapper.- Parameters:
pdxInstance-PdxInstanceobject used to back this wrapper; must not be null.- Returns:
- a new instance of
PdxInstanceWrapperinitialized with the givenPdxInstance. - Throws:
IllegalArgumentException- ifPdxInstanceis null.- See Also:
-
PdxInstancePdxInstanceWrapper(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 givenPdxInstanceis an instance ofPdxInstanceWrapperthen this factory method will unwrap thePdxInstanceWrapperreturning the underlying,delegatePdxInstance. Otherwise, the givenPdxInstanceis returned.- Parameters:
pdxInstance-PdxInstanceto unwrap; may be null.- Returns:
- the unwrapped
PdxInstance. - See Also:
-
PdxInstancegetDelegate()
-
getDelegate
public org.apache.geode.pdx.PdxInstance getDelegate()Returns a reference to the configured, underlyingPdxInstancebacking this wrapper.- Returns:
- a reference to the configured, underlying
PdxInstancebacking this wrapper; never null. - See Also:
-
PdxInstance
-
getObjectMapper
Returns anOptionalreference to a configured JacksonObjectMapperused to deserialize theJSONgenerated fromPDXback into anObject. This method is meant ot be overridden bysubclasses. -
getClassName
- Specified by:
getClassNamein interfaceorg.apache.geode.pdx.PdxInstance
-
isDeserializable
public boolean isDeserializable()- Specified by:
isDeserializablein interfaceorg.apache.geode.pdx.PdxInstance
-
isEnum
public boolean isEnum()- Specified by:
isEnumin interfaceorg.apache.geode.pdx.PdxInstance
-
getField
- Specified by:
getFieldin interfaceorg.apache.geode.pdx.PdxInstance
-
getFieldNames
- Specified by:
getFieldNamesin interfaceorg.apache.geode.pdx.PdxInstance
-
getIdentifier
- Returns:
- the
identifierfor thisPdxInstance; never null. - Throws:
IllegalStateException- if thePdxInstancedoes not have an id.- See Also:
-
getId
Searches for a PDXfield namecalled id on thisPdxInstanceand returns itsvalueas theidentifierfor, oridentityof, thisPdxInstance.- Returns:
- the
valueof the idfieldon thisPdxInstance. - Throws:
IllegalStateException- if thisPdxInstancedoes not have an id.- See Also:
-
getAtIdentifier
Searches for a PDXfielddeclared by the @identifier metadatafieldon thisPdxInstanceand returns thevalueof thisfieldas theidentifierfor, oridentityof, thisPdxInstance.- Returns:
- the
valueof thefielddeclared in the @identifier metadatafieldon thisPdxInstance. - Throws:
IllegalStateException- if thePdxInstancedoes not have an id.- See Also:
-
PdxInstance
-
isIdentityField
- Specified by:
isIdentityFieldin interfaceorg.apache.geode.pdx.PdxInstance
-
getObject
Materializes anObjectfrom the PDX bytes described by thisPdxInstance. If these PDX bytes describe anObjectparsed from JSON, then the JSON is reconstructed from thisPdxInstanceand mapped to an instance of thetypeidentified by the @type metadata PDXfieldusing Jackson'sObjectMapper.- Specified by:
getObjectin interfaceorg.apache.geode.pdx.PdxInstance- Returns:
- an
Objectconstructed from the PDX bytes described by thisPdxInstance. - See Also:
-
ObjectMapperObjectgetObjectMapper()
-
createWriter
public org.apache.geode.pdx.WritablePdxInstance createWriter()- Specified by:
createWriterin interfaceorg.apache.geode.pdx.PdxInstance
-
hasField
- Specified by:
hasFieldin interfaceorg.apache.geode.pdx.PdxInstance
-
sendTo
- Specified by:
sendToin interfaceorg.apache.geode.internal.Sendable- Throws:
IOException
-
toString
Returns aStringrepresentation of thisPdxInstance.
-