Class AbstractStringSerializer<T>

    • Constructor Detail

      • AbstractStringSerializer

        protected AbstractStringSerializer​(@Nonnull
                                           BinarySerializer<T> serializer)
        Constructs a new BinarySerializer.
        Parameters:
        serializer - the serializer to use before applying a String encoding or decoding
    • Method Detail

      • serialize

        @Nonnull
        public String serialize​(T t)
        Description copied from interface: Serializer
        Write an object of type T into its basic representation.
        Specified by:
        serialize in interface Serializer<T,​String>
        Parameters:
        t - the object to serialize
        Returns:
        the serialized object
      • deserialize

        @Nonnull
        public T deserialize​(String data)
        Description copied from interface: Serializer
        Reads and assembles an object of type T from the given data.
        Specified by:
        deserialize in interface Serializer<T,​String>
        Parameters:
        data - the basic representation of the object
        Returns:
        the deserialized object
      • encode

        @Nonnull
        protected abstract String encode​(byte[] data)
        Encodes a byte array into its literal representation.
        Parameters:
        data - a byte array
        Returns:
        the literal representation of the byte array
      • decode

        @Nonnull
        protected abstract byte[] decode​(String data)
        Decodes a String into its binary representation.
        Parameters:
        data - a string
        Returns:
        the binary representation of the string