Class AbstractStringSerializer<T>
- java.lang.Object
-
- org.atlanmod.commons.io.serializer.AbstractStringSerializer<T>
-
- Type Parameters:
T- the type of (de)serialized objects
- All Implemented Interfaces:
Function<T,String>,Converter<T,String>,Serializer<T,String>,StringSerializer<T>
@ParametersAreNonnullByDefault public abstract class AbstractStringSerializer<T> extends Object implements StringSerializer<T>
An abstractStringSerializerfor objects of typeT.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractStringSerializer(BinarySerializer<T> serializer)Constructs a newBinarySerializer.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract byte[]decode(String data)Decodes aStringinto its binary representation.Tdeserialize(String data)Reads and assembles an object of typeTfrom the givendata.protected abstract Stringencode(byte[] data)Encodes abytearray into its literal representation.Stringserialize(T t)Write an object of typeTinto its basic representation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.atlanmod.commons.io.serializer.Serializer
convert, revert
-
-
-
-
Constructor Detail
-
AbstractStringSerializer
protected AbstractStringSerializer(@Nonnull BinarySerializer<T> serializer)Constructs a newBinarySerializer.- Parameters:
serializer- the serializer to use before applying aStringencoding or decoding
-
-
Method Detail
-
serialize
@Nonnull public String serialize(T t)
Description copied from interface:SerializerWrite an object of typeTinto its basic representation.- Specified by:
serializein interfaceSerializer<T,String>- Parameters:
t- the object to serialize- Returns:
- the serialized object
-
deserialize
@Nonnull public T deserialize(String data)
Description copied from interface:SerializerReads and assembles an object of typeTfrom the givendata.- Specified by:
deserializein interfaceSerializer<T,String>- Parameters:
data- the basic representation of the object- Returns:
- the deserialized object
-
encode
@Nonnull protected abstract String encode(byte[] data)
Encodes abytearray 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 aStringinto its binary representation.- Parameters:
data- a string- Returns:
- the binary representation of the string
-
-