Class JsonMessageSerde

java.lang.Object
energy.eddie.cim.serde.JsonMessageSerde
All Implemented Interfaces:
MessageSerde

public class JsonMessageSerde extends Object implements MessageSerde
A MessageSerde that serializes to JSON. Respects jakarta XML annotation.
  • Constructor Details

    • JsonMessageSerde

      public JsonMessageSerde()
  • Method Details

    • serialize

      public byte[] serialize(Object message) throws SerializationException
      Description copied from interface: MessageSerde
      Serializes an object to a byte array.
      Specified by:
      serialize in interface MessageSerde
      Parameters:
      message - the object to be serialized.
      Returns:
      a serialized byte array
      Throws:
      SerializationException - if the serialization failed
    • deserialize

      public <T> T deserialize(byte[] message, Class<T> messageType) throws DeserializationException
      Description copied from interface: MessageSerde
      Deserializes a message to a given class.
      Specified by:
      deserialize in interface MessageSerde
      Type Parameters:
      T - the destination type.
      Parameters:
      message - the message that should be deserialized.
      messageType - the class of the destination type.
      Returns:
      the deserialized object.
      Throws:
      DeserializationException - if the deserialization fails.