Class JacksonXmlSerdes

java.lang.Object
io.github.cjstehno.testthings.serdes.JacksonXmlSerdes
All Implemented Interfaces:
SerdesProvider

public class JacksonXmlSerdes extends Object implements SerdesProvider
A SerdesProvider that uses the Jackson XML data format for serialization and deserialization.
  • Constructor Details

    • JacksonXmlSerdes

      public JacksonXmlSerdes()
      Creates an instance with the default configured XmlMapper.
  • Method Details

    • serializeToBytes

      public byte[] serializeToBytes(Object object) throws IOException
      Description copied from interface: SerdesProvider
      Serialize the object to bytes.
      Specified by:
      serializeToBytes in interface SerdesProvider
      Parameters:
      object - the object
      Returns:
      a byte array containing the serialized object
      Throws:
      IOException - if there is a problem
    • serializeToString

      public String serializeToString(Object object) throws IOException
      Description copied from interface: SerdesProvider
      Serialize the object to a string.
      Specified by:
      serializeToString in interface SerdesProvider
      Parameters:
      object - the object
      Returns:
      a string containing the serialized object
      Throws:
      IOException - if there is a problem
    • deserialize

      public <T> T deserialize(byte[] bytes, Class<? extends T> type) throws IOException
      Description copied from interface: SerdesProvider
      Deserializes the byte array to an object of the specified type.
      Specified by:
      deserialize in interface SerdesProvider
      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

      public <T> T deserialize(String string, Class<? extends T> type) throws IOException
      Description copied from interface: SerdesProvider
      Deserializes the string to an object of the specified type.
      Specified by:
      deserialize in interface SerdesProvider
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object