Interface PersistentSerializer<T extends PersistentData,S extends com.google.protobuf.Message>

Type Parameters:
T - a subclass of PersistentData
S - a subclass of Message
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 Details

    • toBytes

      byte[] toBytes(T data, @Nullable SerializationContext context) throws SerializeException
      Serializes the given T PersistentData into a byte array.
      Parameters:
      data - The T PersistentData to 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

      String toJson(T data, @Nullable SerializationContext context) throws SerializeException
      Serializes the given T PersistentData into a JSON string.
      Parameters:
      data - The T PersistentData to 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 T PersistentData into a JsonElement.
      Parameters:
      data - The T PersistentData to 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

      S toProtoMessage(T data, @Nullable SerializationContext context) throws SerializeException
      Serializes the given T PersistentData into a Protobuf Message.
      Parameters:
      data - The T PersistentData to 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

      T fromBytes(byte[] bytes, @Nullable DeserializationContext context) throws DeserializeException
      Deserializes the given byte array into a T PersistentData object.
      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

      T fromJson(String json, @Nullable DeserializationContext context) throws DeserializeException
      Deserializes the given JSON string into a T PersistentData object.
      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 given JsonElement into a T PersistentData object.
      Parameters:
      jsonElement - The JsonElement to deserialize.
      context - The deserialization context to use for deserialization.
      Returns:
      The deserialized persistent data object.
      Throws:
      DeserializeException - If an error occurs during deserialization.
    • fromProtoMessage

      T fromProtoMessage(S message, @Nullable DeserializationContext context) throws DeserializeException
      Deserializes the given Protobuf Message into a T PersistentData object.
      Parameters:
      message - The S Protobuf Message to deserialize.
      context - The deserialization context to use for deserialization.
      Returns:
      The deserialized persistent data object.
      Throws:
      DeserializeException - If an error occurs during deserialization.
    • getCompatibleClass

      @Nonnull Class<T> getCompatibleClass()
      The T PersistentData class that is compatible with this serializer.
      Returns:
      The T PersistentData class.