Interface ObjectSerializer<T extends Serializable>

Type Parameters:
T - the type of the serialized form
All Known Implementing Classes:
GsonObjectSerializer

public interface ObjectSerializer<T extends Serializable>
A serializer of objects, i.e., a class that can convert an arbitrary object to a serialized form and back.
Author:
RealLifeDeveloper
  • Method Summary

    Modifier and Type
    Method
    Description
    <U> U
    deserialize(T serializedObject, Class<U> objectType)
    Given the serialized representation of an object, converts it back to the object.
    serialize(Object object)
    Converts an object to its serialized form.
  • Method Details

    • serialize

      T serialize(Object object)
      Converts an object to its serialized form.

      The implementation should support serializing null values.

      Parameters:
      object - the object to serialize, can be null
      Returns:
      the serialized representation of object
    • deserialize

      <U> U deserialize(T serializedObject, Class<U> objectType)
      Given the serialized representation of an object, converts it back to the object.
      Type Parameters:
      U - the type of the object
      Parameters:
      serializedObject - the serialized form of an object
      objectType - the concrete class of the serialized object
      Returns:
      the object represented by serializedObject
      Throws:
      IllegalArgumentException - if any argument is null