Class ContextBoundSerdes
java.lang.Object
io.micronaut.serde.support.util.ContextBoundSerdes
Tracks the serde beans created with the context of a document, such as a user serde taking
@Parameter EncoderContext, while a serde is specialized, so that the serdes of a bean that are kept
between documents are specialized again for each document when they contain one.- Since:
- 3.3.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceCreates a specific deserializer for each context.static interfaceCreates a specific serializer for each context. -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreated()Records that a serde bean was created with the context of the current specialization.static <T> Deserializer<T> specialize(ContextBoundSerdes.DeserializerFactory<T> factory, Deserializer.DecoderContext context) Specializes a deserializer that a bean keeps between documents.static <T> Serializer<T> specialize(ContextBoundSerdes.SerializerFactory<T> factory, Serializer.EncoderContext context) Specializes a serializer that a bean keeps between documents.
-
Method Details
-
created
public static void created()Records that a serde bean was created with the context of the current specialization. -
specialize
public static <T> Serializer<T> specialize(ContextBoundSerdes.SerializerFactory<T> factory, Serializer.EncoderContext context) throws SerdeException Specializes a serializer that a bean keeps between documents. If specializing it creates a serde bean bound to the context, the serializer is specialized again for the context of each document.- Type Parameters:
T- The type- Parameters:
factory- The factory of the specific serializercontext- The context of the current document- Returns:
- The serializer to keep
- Throws:
SerdeException- If it cannot be created
-
specialize
public static <T> Deserializer<T> specialize(ContextBoundSerdes.DeserializerFactory<T> factory, Deserializer.DecoderContext context) throws SerdeException Specializes a deserializer that a bean keeps between documents. If specializing it creates a serde bean bound to the context, the deserializer is specialized again for the context of each document.- Type Parameters:
T- The type- Parameters:
factory- The factory of the specific deserializercontext- The context of the current document- Returns:
- The deserializer to keep
- Throws:
SerdeException- If it cannot be created
-