Class CodecAdapter<T,S>

java.lang.Object
me.a8kj.config.template.experimental.codec.CodecAdapter<T,S>
Type Parameters:
T - the domain object type
S - the serialized representation type

public class CodecAdapter<T,S> extends Object
Provides a unified abstraction for bidirectional data transformation between domain objects and their serialized representations.

Note: This is an experimental feature and is currently considered unstable. This adapter composes both a Serializer and a Deserializer to ensure consistent encoding and decoding logic across the application. It serves as a central conversion bridge between the domain layer and external storage or transport layers.

Since:
0.3
Author:
a8kj7sea
  • Constructor Details

    • CodecAdapter

      public CodecAdapter()
  • Method Details

    • serialize

      @Nullable public S serialize(@Nullable T obj)
      Serializes the given domain object into its encoded representation.

      Delegates the transformation process to the configured Serializer.

      Parameters:
      obj - the domain object to serialize
      Returns:
      the serialized representation, or null if the object is null or serialization fails
    • deserialize

      @Nullable public T deserialize(@Nullable S data)
      Deserializes the provided data into a domain object instance.

      Delegates the reconstruction process to the configured Deserializer. If the provided data is null or invalid, the result may be null.

      Parameters:
      data - the serialized data to deserialize, may be null
      Returns:
      the reconstructed domain object, or null if deserialization fails or input is null