T
- the object type@FunctionalInterface public interface Serializer<T>
Deserializer
Modifier and Type | Method and Description |
---|---|
void |
serialize(T object,
OutputStream outputStream)
Write an object of type T to the given OutputStream.
|
default byte[] |
serializeToByteArray(T object)
Turn an object of type T into a serialized byte array.
|
void serialize(T object, OutputStream outputStream) throws IOException
Note: Implementations should not close the given OutputStream (or any decorators of that OutputStream) but rather leave this up to the caller.
object
- the object to serializeoutputStream
- the output streamIOException
- in case of errors writing to the streamdefault byte[] serializeToByteArray(T object) throws IOException
object
- the object to serializeIOException
- in case of serialization failure