Package energy.eddie.cim.serde
Interface MessageSerde
- All Known Implementing Classes:
JsonMessageSerde,XmlMessageSerde
public interface MessageSerde
A serde is a SERializer-DEserializer, which supports one or multiple formats to serialize and deserialize objects to and from.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> Tdeserialize(byte[] message, MessageType messageType) Deserializes a message based on aMessageType.<T> Tdeserialize(byte[] message, Class<T> messageType) Deserializes a message to a given class.default <T> List<T> deserializeList(byte[] message, MessageType elementType) Deserializes a message to a list of elements based on aMessageType.<T> List<T> deserializeList(byte[] message, Class<T> elementType) Deserializes a message to a list of elements based on the given elementType.byte[]Serializes an object to a byte array.
-
Method Details
-
serialize
Serializes an object to a byte array.- Parameters:
message- the object to be serialized.- Returns:
- a serialized byte array
- Throws:
SerializationException- if the serialization failed
-
deserialize
Deserializes a message to a given class.- 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.
-
deserialize
Deserializes a message based on aMessageType.- Type Parameters:
T- the destination type.- Parameters:
message- the message that should be deserialized.messageType- the type of the destination message.- Returns:
- the deserialized object.
- Throws:
DeserializationException- if the deserialization fails.
-
deserializeList
Deserializes a message to a list of elements based on the given elementType.- Type Parameters:
T- the element type.- Parameters:
message- the message that should be deserialized.elementType- the type of the elements of the destination list.- Returns:
- the deserialized list.
- Throws:
DeserializationException- if the deserialization fails.
-
deserializeList
default <T> List<T> deserializeList(byte[] message, MessageType elementType) throws DeserializationException Deserializes a message to a list of elements based on aMessageType.- Type Parameters:
T- the element type.- Parameters:
message- the message that should be deserialized.elementType- the type of the elements of the destination list.- Returns:
- the deserialized list.
- Throws:
DeserializationException- if the deserialization fails.
-