Class GeneratedSerdeLazyUtil

java.lang.Object
io.micronaut.serde.util.GeneratedSerdeLazyUtil

@Internal public final class GeneratedSerdeLazyUtil extends Object
Lazy property serdes used by generated serdes for properties whose type can refer back to the generated type, such as List<Self>. Generated serdes resolve their property serdes on construction and the registry creates a new generated serde for every specific lookup, so resolving such a property eagerly would construct the owning serde again without end.

The delegate is resolved once, on first use, and cached.

Since:
3.2.2
  • Method Details

    • lazySerializer

      public static <T> Serializer<T> lazySerializer(Serializer.EncoderContext context, io.micronaut.core.type.Argument<T> type)
      Creates a serializer that resolves the specific serializer for the given type on first use.
      Type Parameters:
      T - The property type
      Parameters:
      context - The encoder context
      type - The property type
      Returns:
      The lazy serializer
    • lazyDeserializer

      public static <T> Deserializer<T> lazyDeserializer(Deserializer.DecoderContext context, io.micronaut.core.type.Argument<T> type)
      Creates a deserializer that resolves the specific deserializer for the given type on first use.
      Type Parameters:
      T - The property type
      Parameters:
      context - The decoder context
      type - The property type
      Returns:
      The lazy deserializer