Interface NullableDeserializer<T>

Type Parameters:
T - The type to deserialize
All Superinterfaces:
Deserializer<T>
All Known Subinterfaces:
NullableSerde<T>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface NullableDeserializer<T> extends Deserializer<T>
Sub-interface of Deserializer for deserializers that allow null. Deals with the decoding of null and delegates to deserializeNonNull(io.micronaut.serde.Decoder, io.micronaut.serde.Deserializer.DecoderContext, io.micronaut.core.type.Argument).
  • Method Details

    • deserialize

      default T deserialize(Decoder decoder, Deserializer.DecoderContext context, io.micronaut.core.type.Argument<? super T> type) throws IOException
      Description copied from interface: Deserializer
      Deserializes from the current state of the Decoder an object of type Deserializer.
      Specified by:
      deserialize in interface Deserializer<T>
      Parameters:
      decoder - The decoder, never null
      context - The decoder context, never null
      type - The generic type to be deserialized
      Returns:
      The deserialized object or null only if Deserializer.allowNull() returns true
      Throws:
      IOException - If an error occurs during deserialization of the object
    • deserializeNonNull

      @NonNull T deserializeNonNull(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) throws IOException
      A method that is invoked when the value is known not to be null.
      Parameters:
      decoder - The decoder
      decoderContext - The decoder context
      type - The type
      Returns:
      The value
      Throws:
      IOException - if something goes wrong during deserialization
    • allowNull

      default boolean allowNull()
      Description copied from interface: Deserializer
      Return true if the decoder can accept the null value by converting it to something else or just returning null.
      Specified by:
      allowNull in interface Deserializer<T>
      Returns:
      Whether the deserializer is allowed to emit null