Interface Serializer<T>
- Type Parameters:
T- The type to be serialized
- All Known Subinterfaces:
CustomizableSerializer<T>, FormattedSerde<T>, FormattedSerializer<T>, NullableSerde<T>, NumberSerde<N>, ObjectSerializer<T>, Serde<T>, SerdeRegistrar<T>, SerializerRegistrar<T>, TemporalSerde<T>
- All Known Implementing Classes:
AbstractBsonSerde, AbstractOracleJsonSerde, BsonRepresentationSerde, ByteBufferSerde, CodecBsonDecoder, CustomizedObjectArraySerializer, DefaultFormattedTemporalSerde, ErrorCatchingSerializer, HealthStatusSerde, InetAddressSerde, InstantSerde, LocalDateSerde, LocalDateTimeSerde, LocalTimeSerde, ObjectArraySerde, ObjectSerializer, OffsetDateTimeSerde, OracleJsonBinarySerde, OracleJsonDurationSerde, OracleJsonLocaleDateSerde, OracleJsonLocaleDateTimeSerde, OracleJsonLocaleTimeSerde, OracleJsonOffsetDateTimeSerde, OracleJsonZonedDateTimeSerde, YearSerde, ZonedDateTimeSerde
Models a build time serializer. That is a class computed at build-time that can
be used to serialize an instance of
T.- Author:
- Jonas Konrad, graemerocher
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceContext object passes to theserialize(Encoder, EncoderContext, Argument, Object)method. -
Method Summary
Modifier and TypeMethodDescriptiondefault Serializer<T> createSpecific(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) Create a more specific serializer for the given definition.default booleanisAbsent(Serializer.EncoderContext context, @Nullable T value) Used forJsonInclude.Include#NON_ABSENTchecking.default booleanisDefault(Serializer.EncoderContext context, T value) Used forJsonInclude.Include#NON_DEFAULTchecking.default booleanisEmpty(Serializer.EncoderContext context, @Nullable T value) Used forJsonInclude.Include#NON_EMPTYchecking.voidserialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) Serializes the given value using the passedEncoder.
-
Method Details
-
createSpecific
default Serializer<T> createSpecific(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) throws SerdeException Create a more specific serializer for the given definition.- Parameters:
context- The encoder contexttype- The type definition including any annotation metadata- Returns:
- The more specific serializer
- Throws:
SerdeException
-
serialize
void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) throws IOException Serializes the given value using the passedEncoder.- Parameters:
encoder- The encoder to usecontext- The encoder context, nevernulltype- Models the generic type of the valuevalue- The value to serialize, nevernull. Callers should encode null values directly.- Throws:
IOException- If an error occurs during serialization
-
isEmpty
Used forJsonInclude.Include#NON_EMPTYchecking.- Parameters:
context- The encoder contextvalue- The check to check- Returns:
- Return
trueif the value is empty
-
isAbsent
Used forJsonInclude.Include#NON_ABSENTchecking.- Parameters:
context- The encoder contextvalue- The value to check- Returns:
- Return
trueif the value is absent
-
isDefault
Used forJsonInclude.Include#NON_DEFAULTchecking.- Parameters:
context- The encoder contextvalue- The check to check- Returns:
- Return
trueif the value is the default value - Since:
- 1.14
-