Interface Serializer<T>

Type Parameters:
T - The type to be serialized
All Known Subinterfaces:
CustomizableSerializer<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, HealthStatusSerde, InetAddressSerde, InstantSerde, LocalDateSerde, LocalDateTimeSerde, LocalTimeSerde, ObjectArraySerde, ObjectSerializer, OffsetDateTimeSerde, OracleJsonBinarySerde, OracleJsonDurationSerde, OracleJsonLocaleDateSerde, OracleJsonLocaleDateTimeSerde, OracleJsonLocaleTimeSerde, OracleJsonOffsetDateTimeSerde, OracleJsonZonedDateTimeSerde, YearSerde, ZonedDateTimeSerde

@Indexed(Serializer.class) public interface Serializer<T>
Models a build time serializer. That is a class computed at build-time that can be used to serialize an instance of Serializer.
Author:
Jonas Konrad, graemerocher
  • Method Details

    • createSpecific

      @NonNull default @NonNull Serializer<T> createSpecific(@NonNull @NonNull Serializer.EncoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? extends T> type) throws SerdeException
      Create a more specific serializer for the given definition.
      Parameters:
      context - The encoder context
      type - The type definition including any annotation metadata
      Returns:
      The more specific serializer
      Throws:
      SerdeException
    • serialize

      void serialize(@NonNull @NonNull Encoder encoder, @NonNull @NonNull Serializer.EncoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? extends T> type, @NonNull T value) throws IOException
      Serializes the given value using the passed Encoder.
      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
    • isEmpty

      default boolean isEmpty(@NonNull @NonNull Serializer.EncoderContext context, @Nullable T value)
      Used for JsonInclude.Include#NON_EMPTY checking.
      Parameters:
      context - The encoder context
      value - The check to check
      Returns:
      Return true if the value is empty
    • isAbsent

      default boolean isAbsent(@NonNull @NonNull Serializer.EncoderContext context, @Nullable T value)
      Used for JsonInclude.Include#NON_ABSENT checking.
      Parameters:
      context - The encoder context
      value - The value to check
      Returns:
      Return true if the value is absent