Interface SerdesProvider

All Known Implementing Classes:
JacksonJsonSerdes, JacksonXmlSerdes, JavaObjectSerdes

public interface SerdesProvider
An interface to allow for different serialization/deserialization framework implementations to use the same testing framework methods. An implementation MUST support the serializeToBytes(Object) and deserialize(byte[],Class) methods - the String-related methods are optional since some serialization formats do not support clean string representations.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    deserialize(byte[] bytes, Class<? extends T> type)
    Deserializes the byte array to an object of the specified type.
    default <T> T
    deserialize(String string, Class<? extends T> type)
    Deserializes the string to an object of the specified type.
    byte[]
    Serialize the object to bytes.
    default String
    Serialize the object to a string.
  • Method Details

    • serializeToBytes

      byte[] serializeToBytes(Object object) throws IOException
      Serialize the object to bytes.
      Parameters:
      object - the object
      Returns:
      a byte array containing the serialized object
      Throws:
      IOException - if there is a problem
    • serializeToString

      default String serializeToString(Object object) throws IOException
      Serialize the object to a string.
      Parameters:
      object - the object
      Returns:
      a string containing the serialized object
      Throws:
      IOException - if there is a problem
    • deserialize

      <T> T deserialize(byte[] bytes, Class<? extends T> type) throws IOException
      Deserializes the byte array to an object of the specified type.
      Type Parameters:
      T - the type of object
      Parameters:
      bytes - the byte array
      type - the object type
      Returns:
      the object instance
      Throws:
      IOException - if there is a problem
    • deserialize

      default <T> T deserialize(String string, Class<? extends T> type) throws IOException
      Deserializes the string to an object of the specified type.
      Type Parameters:
      T - the type of object
      Parameters:
      string - the string
      type - the object type
      Returns:
      the object instance
      Throws:
      IOException - if there is a problem