Class DeserializingObject<T, S extends SerializedObject<T>>
java.lang.Object
io.fluxzero.sdk.common.serialization.DeserializingObject<T,S>
- Type Parameters:
T- The raw data type of the serialized object (e.g., String or byte[])S- The specificSerializedObjecttype used to represent the serialized payload
A wrapper around a
SerializedObject that supports lazy deserialization of its payload.
This class defers the deserialization of the underlying object until it is first accessed via getPayload()
or getPayloadAs(Type). The result is then memoized to avoid repeated deserialization.
This is typically used for messages that may not require full deserialization (e.g. for routing or filtering). It is
extended by DeserializingMessage which adds additional context and metadata.
-
Constructor Summary
ConstructorsConstructorDescriptionDeserializingObject(S serializedObject, Function<Type, Object> payload) Creates a newDeserializingObjectwith the given serialized representation and deserializer function. -
Method Summary
Modifier and TypeMethodDescriptionprotected MemoizingFunction<Type, Object> Returns the memoized deserialization function used to deserialize the payload.<V> VReturns the deserialized payload using the default target type (Object.class).<V> VgetPayloadAs(Type type) Returns the deserialized payload using the specified targetType.Class<?> Attempts to resolve the declared payload class usingReflectionUtils.classForName(String)and throws an exception if the class cannot be found.intReturns the revision number of the serialized payload, if available.getType()Returns the declared type of the payload (e.g., fully qualified class name), ornullif unknown.booleanReturnstrueif the payload has already been deserialized using the default type.
-
Constructor Details
-
DeserializingObject
-
-
Method Details
-
getObjectFunction
Returns the memoized deserialization function used to deserialize the payload. This method is protected for use in subclasses. -
getPayload
public <V> V getPayload()Returns the deserialized payload using the default target type (Object.class). The result is cached and reused on subsequent calls. -
getPayloadAs
-
isDeserialized
public boolean isDeserialized()Returnstrueif the payload has already been deserialized using the default type. -
getType
Returns the declared type of the payload (e.g., fully qualified class name), ornullif unknown. -
getRevision
public int getRevision()Returns the revision number of the serialized payload, if available. -
getPayloadClass
Attempts to resolve the declared payload class usingReflectionUtils.classForName(String)and throws an exception if the class cannot be found.- Returns:
- the
Classcorresponding to the declared type, ornullif not resolvable
-