Interface Serializer<T>
- Type Parameters:
T
- the object type
- All Known Implementing Classes:
DefaultSerializer
,SerializationDelegate
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
A strategy interface for streaming an object to an OutputStream.
- Since:
- 3.0.5
- Author:
- Gary Russell, Mark Fisher, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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.
-
Method Details
-
serialize
Write an object of type T to the given OutputStream.Note: Implementations should not close the given OutputStream (or any decorators of that OutputStream) but rather leave this up to the caller.
- Parameters:
object
- the object to serializeoutputStream
- the output stream- Throws:
IOException
- in case of errors writing to the stream
-
serializeToByteArray
Turn an object of type T into a serialized byte array.- Parameters:
object
- the object to serialize- Returns:
- the resulting byte array
- Throws:
IOException
- in case of serialization failure- Since:
- 5.2.7
-