Class ObjectSerializer

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected static com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
      Shared Json serializer/deserializer as per Jackson's documentation.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected ObjectSerializer()
      Default constructor to avoid class from being instantiated outside package but still inherited.
    • Field Detail

      • OBJECT_MAPPER

        protected static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER
        Shared Json serializer/deserializer as per Jackson's documentation.
    • Constructor Detail

      • ObjectSerializer

        protected ObjectSerializer()
        Default constructor to avoid class from being instantiated outside package but still inherited.
    • Method Detail

      • serialize

        public byte[] serialize​(Object state)
                         throws IOException
        Serializes a given state object into byte array.
        Parameters:
        state - State object to be serialized.
        Returns:
        Array of bytes[] with the serialized content.
        Throws:
        IOException - In case state cannot be serialized.
      • deserialize

        public <T> T deserialize​(byte[] content,
                                 TypeRef<T> type)
                          throws IOException
        Deserializes the byte array into the original object.
        Type Parameters:
        T - Generic type of the object being deserialized.
        Parameters:
        content - Content to be parsed.
        type - Type of the object being deserialized.
        Returns:
        Object of type T.
        Throws:
        IOException - In case content cannot be deserialized.
      • deserialize

        public <T> T deserialize​(byte[] content,
                                 Class<T> clazz)
                          throws IOException
        Deserializes the byte array into the original object.
        Type Parameters:
        T - Generic type of the object being deserialized.
        Parameters:
        content - Content to be parsed.
        clazz - Type of the object being deserialized.
        Returns:
        Object of type T.
        Throws:
        IOException - In case content cannot be deserialized.
      • parseNode

        public com.fasterxml.jackson.databind.JsonNode parseNode​(byte[] content)
                                                          throws IOException
        Parses the JSON content into a node for fine-grained processing.
        Parameters:
        content - JSON content.
        Returns:
        JsonNode.
        Throws:
        IOException - In case content cannot be parsed.