Package io.micronaut.core.serialize
Interface ObjectSerializer
-
- All Known Implementing Classes:
JdkSerializer
public interface ObjectSerializerInterface for implementations capable of serializing objects.- Since:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description static ObjectSerializerJDKThe default JDK serializer.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default java.util.Optional<java.lang.Object>deserialize(byte[] bytes)Deserialize the given object to bytes.default <T> java.util.Optional<T>deserialize(byte[] bytes, Argument<T> requiredType)Deserialize the given object to bytes.default <T> java.util.Optional<T>deserialize(byte[] bytes, java.lang.Class<T> requiredType)Deserialize the given object to bytes.default <T> java.util.Optional<T>deserialize(java.io.InputStream inputStream, Argument<T> requiredType)Deserialize the given object to bytes.<T> java.util.Optional<T>deserialize(java.io.InputStream inputStream, java.lang.Class<T> requiredType)Deserialize the given object to bytes.default java.util.Optional<byte[]>serialize(java.lang.Object object)Serialize the given object to a byte[].voidserialize(java.lang.Object object, java.io.OutputStream outputStream)Serialize the given object to a byte[].
-
-
-
Field Detail
-
JDK
static final ObjectSerializer JDK
The default JDK serializer.
-
-
Method Detail
-
serialize
void serialize(@Nullable java.lang.Object object, java.io.OutputStream outputStream) throws SerializationException
Serialize the given object to a byte[].- Parameters:
object- The object to serializeoutputStream- The output stream- Throws:
SerializationException- if there is a serialization problem
-
deserialize
<T> java.util.Optional<T> deserialize(@Nullable java.io.InputStream inputStream, java.lang.Class<T> requiredType) throws SerializationException
Deserialize the given object to bytes.- 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
default <T> java.util.Optional<T> deserialize(@Nullable java.io.InputStream inputStream, Argument<T> requiredType) throws SerializationException
Deserialize the given object to bytes.- 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- Since:
- 2.0
-
serialize
default java.util.Optional<byte[]> serialize(@Nullable java.lang.Object object) throws SerializationException
Serialize the given object to a byte[].- Parameters:
object- The object to serialize- Returns:
- An optional of the bytes of the object
- Throws:
SerializationException- if there is a serialization problem
-
deserialize
default <T> java.util.Optional<T> deserialize(@Nullable byte[] bytes, java.lang.Class<T> requiredType) throws SerializationException
Deserialize the given object to bytes.- Type Parameters:
T- The required generic type- Parameters:
bytes- The byte arrayrequiredType- The required type- Returns:
- An
Optionalof the object - Throws:
SerializationException- if there is a serialization problem
-
deserialize
default <T> java.util.Optional<T> deserialize(@Nullable byte[] bytes, Argument<T> requiredType) throws SerializationException
Deserialize the given object to bytes.- Type Parameters:
T- The required generic type- Parameters:
bytes- The byte arrayrequiredType- The required type- Returns:
- An
Optionalof the object - Throws:
SerializationException- if there is a serialization problem- Since:
- 2.0
-
deserialize
default java.util.Optional<java.lang.Object> deserialize(@Nullable byte[] bytes) throws SerializationException
Deserialize the given object to bytes.- Parameters:
bytes- The byte array- Returns:
- An
Optionalof the object - Throws:
SerializationException- if there is a serialization problem
-
-