Interface SerDes

All Known Implementing Classes:
DurableInputOutputSerDes, FileSystemSerDes, JacksonSerDes

public interface SerDes
Interface for serialization and deserialization of objects.

Implementations must support both simple types via Class and complex generic types via TypeToken.

  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    deserialize(String data, TypeToken<T> typeToken)
    Deserializes a JSON string to an object of the specified generic type.
    default <T> T
    deserialize(String data, TypeToken<T> typeToken, SerDesContext context)
    Deserializes an operation payload with its stable execution and entity identity.
    Serializes an object to a JSON string.
    default String
    serialize(Object value, SerDesContext context)
    Serializes an operation payload with its stable execution and entity identity.
  • Method Details

    • serialize

      String serialize(Object value)
      Serializes an object to a JSON string.
      Parameters:
      value - the object to serialize
      Returns:
      the JSON string representation, or null if value is null
    • serialize

      default String serialize(Object value, SerDesContext context)
      Serializes an operation payload with its stable execution and entity identity.

      The default preserves existing implementations. Override this method when serialization needs external storage. References returned by such implementations must remain readable after later writes for the same entity.

    • deserialize

      <T> T deserialize(String data, TypeToken<T> typeToken)
      Deserializes a JSON string to an object of the specified generic type.

      This method supports complex generic types like List<MyObject> or Map<String, MyObject> that cannot be represented by a simple Class object.

      Usage example:

      
       List<String> items = serDes.deserialize(json, new TypeToken<List<String>>() {});
       
      Type Parameters:
      T - the target type
      Parameters:
      data - the JSON string to deserialize
      typeToken - the type token capturing the generic type information
      Returns:
      the deserialized object, or null if data is null
    • deserialize

      default <T> T deserialize(String data, TypeToken<T> typeToken, SerDesContext context)
      Deserializes an operation payload with its stable execution and entity identity.

      The default preserves existing implementations. The context identifies the consuming operation; externally produced callback and invoke results may have been serialized with a different context.