Class ContextBoundSerdes

java.lang.Object
io.micronaut.serde.support.util.ContextBoundSerdes

@Internal public final class ContextBoundSerdes extends Object
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
  • 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 serializer
      context - 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 deserializer
      context - The context of the current document
      Returns:
      The deserializer to keep
      Throws:
      SerdeException - If it cannot be created