Package io.micronaut.core.serialize
Interface ObjectSerializer
- All Known Implementing Classes:
JacksonObjectSerializer
,JdkSerializer
,JsonObjectSerializer
public interface ObjectSerializer
Interface for implementations capable of serializing objects.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptiondeserialize
(@io.micronaut.core.annotation.Nullable byte[] bytes) Deserialize the given object to bytes.default <T> Optional<T>
deserialize
(@io.micronaut.core.annotation.Nullable byte[] bytes, Argument<T> requiredType) Deserialize the given object to bytes.default <T> Optional<T>
deserialize
(@io.micronaut.core.annotation.Nullable byte[] bytes, Class<T> requiredType) Deserialize the given object to bytes.default <T> Optional<T>
deserialize
(@Nullable InputStream inputStream, Argument<T> requiredType) Deserialize the given object to bytes.<T> Optional<T>
deserialize
(@Nullable InputStream inputStream, Class<T> requiredType) Deserialize the given object to bytes.default Optional<byte[]>
Serialize the given object to a byte[].void
serialize
(@Nullable Object object, OutputStream outputStream) Serialize the given object to a byte[].
-
Field Details
-
JDK
The default JDK serializer.
-
-
Method Details
-
serialize
void serialize(@Nullable @Nullable Object object, 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> Optional<T> deserialize(@Nullable @Nullable InputStream inputStream, 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
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
deserialize
default <T> Optional<T> deserialize(@Nullable @Nullable 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
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem- Since:
- 2.0
-
serialize
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> Optional<T> deserialize(@Nullable @io.micronaut.core.annotation.Nullable byte[] bytes, 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
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-
deserialize
default <T> Optional<T> deserialize(@Nullable @io.micronaut.core.annotation.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
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem- Since:
- 2.0
-
deserialize
default Optional<Object> deserialize(@Nullable @io.micronaut.core.annotation.Nullable byte[] bytes) throws SerializationException Deserialize the given object to bytes.- Parameters:
bytes
- The byte array- Returns:
- An
Optional
of the object - Throws:
SerializationException
- if there is a serialization problem
-