Interface PersistentSerializer<T extends PersistentData,S extends com.google.protobuf.Message>
- Type Parameters:
T- a subclass ofPersistentDataS- a subclass ofMessage
- All Known Implementing Classes:
AnnotationPersistentData.Serializer,DelegatingPersistentSerializer
public interface PersistentSerializer<T extends PersistentData,S extends com.google.protobuf.Message>
An interface that provides methods for serializing and deserializing
PersistentData.-
Method Summary
Modifier and TypeMethodDescriptionfromBytes(byte[] bytes, DeserializationContext context) Deserializes the given byte array into a TPersistentDataobject.fromJson(String json, DeserializationContext context) Deserializes the given JSON string into a TPersistentDataobject.fromJsonElement(com.inductiveautomation.ignition.common.gson.JsonElement jsonElement, DeserializationContext context) Deserializes the givenJsonElementinto a TPersistentDataobject.fromProtoMessage(S message, DeserializationContext context) Deserializes the given ProtobufMessageinto a TPersistentDataobject.The TPersistentDataclass that is compatible with this serializer.byte[]toBytes(T data, SerializationContext context) Serializes the given TPersistentDatainto a byte array.toJson(T data, SerializationContext context) Serializes the given TPersistentDatainto a JSON string.com.inductiveautomation.ignition.common.gson.JsonElementtoJsonElement(T data, SerializationContext context) Serializes the given TPersistentDatainto aJsonElement.toProtoMessage(T data, SerializationContext context) Serializes the given TPersistentDatainto a ProtobufMessage.
-
Method Details
-
toBytes
Serializes the given TPersistentDatainto a byte array.- Parameters:
data- The TPersistentDatato serialize.context- The serialization context to use for serialization.- Returns:
- The serialized data as a byte array.
- Throws:
SerializeException- If an error occurs during serialization.
-
toJson
Serializes the given TPersistentDatainto a JSON string.- Parameters:
data- The TPersistentDatato serialize.context- The serialization context to use for serialization.- Returns:
- The serialized data as a JSON string.
- Throws:
SerializeException- If an error occurs during serialization.
-
toJsonElement
com.inductiveautomation.ignition.common.gson.JsonElement toJsonElement(T data, @Nullable SerializationContext context) throws SerializeException Serializes the given TPersistentDatainto aJsonElement.- Parameters:
data- The TPersistentDatato serialize.context- The serialization context to use for serialization.- Returns:
- The serialized data as a
JsonElement. - Throws:
SerializeException- If an error occurs during serialization.
-
toProtoMessage
Serializes the given TPersistentDatainto a ProtobufMessage.- Parameters:
data- The TPersistentDatato serialize.context- The serialization context to use for serialization.- Returns:
- The serialized data as an S
Message. - Throws:
SerializeException- If an error occurs during serialization.
-
fromBytes
Deserializes the given byte array into a TPersistentDataobject.- Parameters:
bytes- The byte array to deserialize.context- The deserialization context to use for deserialization.- Returns:
- The deserialized persistent data object.
- Throws:
DeserializeException- If an error occurs during deserialization.
-
fromJson
Deserializes the given JSON string into a TPersistentDataobject.- Parameters:
json- The JSON string to deserialize.context- The deserialization context to use for deserialization.- Returns:
- The deserialized persistent data object.
- Throws:
DeserializeException- If an error occurs during deserialization.
-
fromJsonElement
T fromJsonElement(com.inductiveautomation.ignition.common.gson.JsonElement jsonElement, @Nullable DeserializationContext context) throws DeserializeException Deserializes the givenJsonElementinto a TPersistentDataobject.- Parameters:
jsonElement- TheJsonElementto deserialize.context- The deserialization context to use for deserialization.- Returns:
- The deserialized persistent data object.
- Throws:
DeserializeException- If an error occurs during deserialization.
-
fromProtoMessage
Deserializes the given ProtobufMessageinto a TPersistentDataobject.- Parameters:
message- The S ProtobufMessageto deserialize.context- The deserialization context to use for deserialization.- Returns:
- The deserialized persistent data object.
- Throws:
DeserializeException- If an error occurs during deserialization.
-
getCompatibleClass
The TPersistentDataclass that is compatible with this serializer.- Returns:
- The T
PersistentDataclass.
-