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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectInputStreamcreateObjectInput(InputStream inputStream, Class<?> requiredType) protected ObjectOutputStreamcreateObjectOutput(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.voidserialize(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, waitMethods 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:ObjectSerializerSerialize the given object to a byte[].- Specified by:
serializein 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:ObjectSerializerDeserialize the given object to bytes.- Specified by:
deserializein interfaceObjectSerializer- Type Parameters:
T- The required generic type- Parameters:
inputStream- The input streamrequiredType- The required type- Returns:
- An
Optionalof 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:ObjectSerializerDeserialize the given object to bytes.- Specified by:
deserializein interfaceObjectSerializer- Type Parameters:
T- The required generic type- Parameters:
inputStream- The input streamrequiredType- The required type- Returns:
- An
Optionalof 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
-