Class DefaultCasterChain.ConvertingSerializedObject<I,O>

java.lang.Object
io.fluxcapacitor.javaclient.common.serialization.casting.DefaultCasterChain.ConvertingSerializedObject<I,O>
Type Parameters:
I - the input data type before conversion
O - 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 Details

    • ConvertingSerializedObject

      public ConvertingSerializedObject(SerializedObject<I> source, Converter<I,O> converter)
      Constructs a ConvertingSerializedObject with deferred conversion.
      Parameters:
      source - the original serialized object
      converter - the converter to apply
  • Method Details

    • data

      public Data<O> data()
      Description copied from interface: SerializedObject
      Returns the serialized payload held by this object.
      Specified by:
      data in interface SerializedObject<I>
      Returns:
      the serialized payload
    • getType

      public String getType()
      Description copied from interface: SerializedObject
      Returns the type identifier for the serialized payload.
      Specified by:
      getType in interface SerializedObject<I>
    • getRevision

      public int getRevision()
      Description copied from interface: SerializedObject
      Returns the revision of the serialized object.
      Specified by:
      getRevision in interface SerializedObject<I>
    • getResult

      public SerializedObject<?> getResult()
      Returns the final SerializedObject after 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