Class DefaultFormattedTemporalSerde<T extends TemporalAccessor>
java.lang.Object
io.micronaut.serde.support.serdes.DefaultFormattedTemporalSerde<T>
- Type Parameters:
T
- The temporal type
- All Implemented Interfaces:
Deserializer<T>
,Serde<T>
,Serializer<T>
,TemporalSerde<T>
- Direct Known Subclasses:
InstantSerde
,LocalDateSerde
,LocalDateTimeSerde
,LocalTimeSerde
,OffsetDateTimeSerde
,ZonedDateTimeSerde
public abstract class DefaultFormattedTemporalSerde<T extends TemporalAccessor>
extends Object
implements TemporalSerde<T>
Super class that can be used for the default date/time formatting.
- Author:
- gkrocher
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.micronaut.serde.Deserializer
Deserializer.DecoderContext
Nested classes/interfaces inherited from interface io.micronaut.serde.Serializer
Serializer.EncoderContext
-
Field Summary
Fields inherited from interface io.micronaut.serde.support.serdes.TemporalSerde
UTC
-
Constructor Summary
ModifierConstructorDescriptionprotected
DefaultFormattedTemporalSerde
(@NonNull SerdeConfiguration configuration, @NonNull DateTimeFormatter defaultStringFormatter) Allows configuring a default time format for temporal date/time types. -
Method Summary
Modifier and TypeMethodDescriptionprotected DefaultFormattedTemporalSerde<T>
createSpecific
(SerdeConfiguration configuration) Create the same serde with new configuration.createSpecific
(Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> context) Create a new child deserializer or return this if non is necessary for the given context.createSpecific
(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) Create a more specific serializer for the given definition.final T
deserialize
(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) Deserializes from the current state of theDecoder
an object of typeDeserializer
.final void
serialize
(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) Serializes the given value using the passedEncoder
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.micronaut.serde.Deserializer
allowNull, deserializeNullable, getDefaultValue
Methods inherited from interface io.micronaut.serde.Serializer
isAbsent, isEmpty
Methods inherited from interface io.micronaut.serde.support.serdes.TemporalSerde
query
-
Constructor Details
-
DefaultFormattedTemporalSerde
protected DefaultFormattedTemporalSerde(@NonNull @NonNull SerdeConfiguration configuration, @NonNull @NonNull DateTimeFormatter defaultStringFormatter) Allows configuring a default time format for temporal date/time types.- Parameters:
configuration
- The configurationdefaultStringFormatter
- Default string formatter to use if the user hasn't configured one
-
-
Method Details
-
createSpecific
public Serializer<T> createSpecific(Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type) Description copied from interface:Serializer
Create a more specific serializer for the given definition.- Specified by:
createSpecific
in interfaceSerializer<T extends TemporalAccessor>
- Specified by:
createSpecific
in interfaceTemporalSerde<T extends TemporalAccessor>
- Parameters:
context
- The encoder contexttype
- The type definition including any annotation metadata- Returns:
- The more specific serializer
-
createSpecific
public Deserializer<T> createSpecific(Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> context) throws SerdeException Description copied from interface:Deserializer
Create a new child deserializer or return this if non is necessary for the given context.- Specified by:
createSpecific
in interfaceDeserializer<T extends TemporalAccessor>
- Specified by:
createSpecific
in interfaceTemporalSerde<T extends TemporalAccessor>
- Parameters:
decoderContext
- The decoder contextcontext
- 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
-
createSpecific
Create the same serde with new configuration.- Parameters:
configuration
- The new configuration- Returns:
- The updated serde
-
serialize
public final void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends T> type, T value) throws IOException Description copied from interface:Serializer
Serializes the given value using the passedEncoder
.- Specified by:
serialize
in interfaceSerializer<T extends TemporalAccessor>
- Parameters:
encoder
- The encoder to usecontext
- The encoder context, nevernull
type
- Models the generic type of the valuevalue
- The value, can benull
- Throws:
IOException
- If an error occurs during serialization
-
deserialize
public final T deserialize(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super T> type) throws IOException Description copied from interface:Deserializer
Deserializes from the current state of theDecoder
an object of typeDeserializer
.- Specified by:
deserialize
in interfaceDeserializer<T extends TemporalAccessor>
- Parameters:
decoder
- The decoder, nevernull
decoderContext
- The decoder context, nevernull
type
- The generic type to be deserialized- Returns:
- The deserialized object or
null
only ifDeserializer.allowNull()
returnstrue
- Throws:
IOException
- If an error occurs during deserialization of the object
-