Package io.micronaut.core.serialize
Class JdkSerializer
java.lang.Object
io.micronaut.core.serialize.JdkSerializer
- All Implemented Interfaces:
ObjectSerializer
A
ObjectSerializer
that uses JDK serialization.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
Fields inherited from interface io.micronaut.core.serialize.ObjectSerializer
JDK
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectInputStream
createObjectInput
(InputStream inputStream, Class<?> requiredType) protected ObjectOutputStream
createObjectOutput
(OutputStream outputStream) <T> Optional<T>
deserialize
(InputStream inputStream, Argument<T> requiredType) Deserialize the given object to bytes.<T> Optional<T>
deserialize
(InputStream inputStream, Class<T> requiredType) Deserialize the given object to bytes.void
serialize
(Object object, OutputStream outputStream) Serialize the given object to a byte[].Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.core.serialize.ObjectSerializer
deserialize, deserialize, deserialize, serialize
-
Constructor Details
-
JdkSerializer
- Parameters:
conversionService
- The conversion service
-
JdkSerializer
public JdkSerializer()Default constructor.
-
-
Method Details
-
serialize
Description copied from interface:ObjectSerializer
Serialize the given object to a byte[].- Specified by:
serialize
in interfaceObjectSerializer
- Parameters:
object
- The object to serializeoutputStream
- The output stream- Throws:
SerializationException
- if there is a serialization problem
-
deserialize
public <T> Optional<T> deserialize(InputStream inputStream, Class<T> requiredType) throws SerializationException Description copied from interface:ObjectSerializer
Deserialize the given object to bytes.- Specified by:
deserialize
in interfaceObjectSerializer
- Type Parameters:
T
- The required generic type- Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- An
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
deserialize
public <T> Optional<T> deserialize(InputStream inputStream, Argument<T> requiredType) throws SerializationException Description copied from interface:ObjectSerializer
Deserialize the given object to bytes.- Specified by:
deserialize
in interfaceObjectSerializer
- Type Parameters:
T
- The required generic type- Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- An
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
createObjectOutput
- Parameters:
outputStream
- The output stream- Returns:
- A new
ObjectOutputStream
- Throws:
IOException
- if there is an error
-
createObjectInput
protected ObjectInputStream createObjectInput(InputStream inputStream, Class<?> requiredType) throws IOException - Parameters:
inputStream
- The input streamrequiredType
- The required type- Returns:
- A
ObjectOutputStream
- Throws:
IOException
- if there is an error
-