Class DefaultCasterChain.ConvertingSerializedObject<I,O>
java.lang.Object
io.fluxzero.sdk.common.serialization.casting.DefaultCasterChain.ConvertingSerializedObject<I,O>
- Type Parameters:
I- the input data type before conversionO- the output data type after conversion
- All Implemented Interfaces:
SerializedObject<O>, HasSource<SerializedObject<I>>
- Enclosing class:
DefaultCasterChain<T, S extends SerializedObject<T>>
protected static class DefaultCasterChain.ConvertingSerializedObject<I,O>
extends Object
implements SerializedObject<O>, HasSource<SerializedObject<I>>
A
SerializedObject wrapper that applies a Converter to translate data from one format to another.
This class enables the DefaultCasterChain to perform casting across multiple intermediate formats,
often used when bridging serialization formats (e.g., JSON → binary, or type-safe objects → byte arrays).
When the actual converted Data is requested, the wrapped converter will be applied lazily and memoized.
The result can be accessed via data() or extracted using getResult().
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConvertingSerializedObject(SerializedObject<I> source, Converter<I, O> converter) Constructs aConvertingSerializedObjectwith deferred conversion. -
Method Summary
Modifier and TypeMethodDescriptiondata()Returns the serialized payload held by this object.Returns the finalSerializedObjectafter conversion.intReturns the revision of the serialized object.getType()Returns the type identifier for the serialized payload.withMetadata(Metadata metadata) Returns a copy of this wrapper whose source carries the given metadata.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SerializedObject
withData
-
Constructor Details
-
ConvertingSerializedObject
Constructs aConvertingSerializedObjectwith deferred conversion.- Parameters:
source- the original serialized objectconverter- the converter to apply
-
-
Method Details
-
data
Description copied from interface:SerializedObjectReturns the serialized payload held by this object.- Specified by:
datain interfaceSerializedObject<I>- Returns:
- the serialized payload
-
getType
Description copied from interface:SerializedObjectReturns the type identifier for the serialized payload.- Specified by:
getTypein interfaceSerializedObject<I>
-
getRevision
public int getRevision()Description copied from interface:SerializedObjectReturns the revision of the serialized object.- Specified by:
getRevisionin interfaceSerializedObject<I>
-
withMetadata
Returns a copy of this wrapper whose source carries the given metadata.- Parameters:
metadata- the replacement metadata- Returns:
- a wrapper around the updated source
-
getResult
Returns the finalSerializedObjectafter conversion.If no transformation occurred (i.e., the result equals the source), the source object is returned directly.
- Returns:
- a converted or original serialized object
-