Package io.micronaut.serde
Interface Deserializer<T>
- Type Parameters:
T- The generic type that the deserializer can deserialize
- All Known Subinterfaces:
CustomizableDeserializer<T>,DeserializerRegistrar<T>,NullableDeserializer<T>,NullableSerde<T>,NumberSerde<N>,Serde<T>,SerdeRegistrar<T>,TemporalSerde<T>,UpdatingDeserializer<T>
- All Known Implementing Classes:
AbstractBsonSerde,AbstractOracleJsonSerde,BsonRepresentationSerde,ByteBufferSerde,CodecBsonDecoder,CustomizedObjectArrayDeserializer,DefaultFormattedTemporalSerde,HealthStatusSerde,InetAddressSerde,InstantSerde,LocalDateSerde,LocalDateTimeSerde,LocalTimeSerde,ObjectArraySerde,ObjectDeserializer,OffsetDateTimeSerde,OracleJsonBinarySerde,OracleJsonDurationSerde,OracleJsonLocaleDateSerde,OracleJsonLocaleDateTimeSerde,OracleJsonLocaleTimeSerde,OracleJsonOffsetDateTimeSerde,OracleJsonZonedDateTimeSerde,YearSerde,ZonedDateTimeSerde
Interface that represents a deserializer.
- Author:
- Jonas Konrad, graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContext object passed to thedeserialize(Decoder, io.micronaut.serde.Deserializer.DecoderContext, io.micronaut.core.type.Argument)method along with the decoder. -
Method Summary
Modifier and TypeMethodDescriptiondefault booleanDeprecated.default @NonNull Deserializer<T>createSpecific(@NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super T> type) Create a new child deserializer or return this if non is necessary for the given context.deserialize(@NonNull Decoder decoder, @NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super T> type) Deserializes from the current state of theDecoderan object of typeDeserializer.default TdeserializeNullable(@NonNull Decoder decoder, @NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super T> type) Deserializes from the current state of theDecoderan object of typeDeserializer.default TgetDefaultValue(@NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super T> type) Obtains a default value that can be returned from this deserializer in the case where a value is absent.
-
Method Details
-
createSpecific
@NonNull default @NonNull Deserializer<T> createSpecific(@NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super T> type) throws SerdeException Create a new child deserializer or return this if non is necessary for the given context.- Parameters:
context- The decoder contexttype- The context, including any annotation metadata and type information to narrow the deserializer type- Returns:
- An instance of the same type of deserializer
- Throws:
SerdeException
-
deserialize
@Nullable T deserialize(@NonNull @NonNull Decoder decoder, @NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super T> type) throws IOException Deserializes from the current state of theDecoderan object of typeDeserializer.- Parameters:
decoder- The decoder, nevernullcontext- The decoder context, nevernulltype- The generic type to be deserialized- Returns:
- The deserialized object or
nullonly ifallowNull()returnstrue - Throws:
IOException- If an error occurs during deserialization of the object
-
deserializeNullable
default T deserializeNullable(@NonNull @NonNull Decoder decoder, @NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super T> type) throws IOException Deserializes from the current state of theDecoderan object of typeDeserializer. If the decoder value isnull, this must be permitted. By default, in this case, this method will returnnull.- Parameters:
decoder- The decoder, nevernullcontext- The decoder context, nevernulltype- The generic type to be deserialized- Returns:
- The deserialized object or
null - Throws:
IOException- If an error occurs during deserialization of the object- Since:
- 2.0.0
-
allowNull
Deprecated.Return true if the decoder can accept the null value by converting it to something else or just returning null.- Returns:
- Whether the deserializer is allowed to emit
null
-
getDefaultValue
@Nullable default T getDefaultValue(@NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super T> type) Obtains a default value that can be returned from this deserializer in the case where a value is absent.- Parameters:
context- The decoder context, nevernulltype- The generic type to be deserialized- Returns:
- The default value
-
deserializeNullable(io.micronaut.serde.Decoder, io.micronaut.serde.Deserializer.DecoderContext, io.micronaut.core.type.Argument<? super T>)instead