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
  • Constructor Details

    • DefaultFormattedTemporalSerde

      protected DefaultFormattedTemporalSerde(@NonNull SerdeConfiguration configuration)
      Allows configuring a default time format for temporal date/time types.
      Parameters:
      configuration - The configuration
  • Method Details

    • getDefaultFormatter

      @NonNull protected abstract DateTimeFormatter getDefaultFormatter()
      Returns:
      The default formatter.
    • 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 passed Encoder.
      Specified by:
      serialize in interface Serializer<T extends TemporalAccessor>
      Parameters:
      encoder - The encoder to use
      context - The encoder context, never null
      type - Models the generic type of the value
      value - The value, can be null
      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 the Decoder an object of type Deserializer.
      Specified by:
      deserialize in interface Deserializer<T extends TemporalAccessor>
      Parameters:
      decoder - The decoder, never null
      decoderContext - 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
    • serializeWithoutFormat

      protected abstract void serializeWithoutFormat(Encoder encoder, Serializer.EncoderContext context, T value, io.micronaut.core.type.Argument<? extends T> type) throws IOException
      Serializes the given value using the passed Encoder.
      Parameters:
      encoder - The encoder to use
      context - The encoder context, never null
      value - The value, can be null
      type - Models the generic type of the value
      Throws:
      IOException - If an error occurs during serialization
    • deserializeNonNullWithoutFormat

      protected abstract T deserializeNonNullWithoutFormat(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