T
- The type to be serialized@Indexed(value=Serializer.class) public interface Serializer<T>
T
.Modifier and Type | Interface and Description |
---|---|
static interface |
Serializer.EncoderContext
Context object passes to the
serialize(Encoder, io.micronaut.serde.Serializer.EncoderContext, Object, io.micronaut.core.type.Argument) method. |
Modifier and Type | Method and Description |
---|---|
default Serializer<T> |
createSpecific(io.micronaut.core.type.Argument<? extends T> type,
Serializer.EncoderContext encoderContext)
Create a more specific serializer for the given definition.
|
default boolean |
isAbsent(T value)
Used for
JsonInclude.Include#NON_ABSENT checking. |
default boolean |
isEmpty(T value)
Used for
JsonInclude.Include#NON_EMPTY checking. |
void |
serialize(Encoder encoder,
Serializer.EncoderContext context,
T value,
io.micronaut.core.type.Argument<? extends T> type)
Serializes the given value using the passed
Encoder . |
@NonNull default Serializer<T> createSpecific(@NonNull io.micronaut.core.type.Argument<? extends T> type, @NonNull Serializer.EncoderContext encoderContext) throws SerdeException
encoderContext
- The encoder contexttype
- The type definition including any annotation metadataSerdeException
void serialize(@NonNull Encoder encoder, @NonNull Serializer.EncoderContext context, @NonNull T value, @NonNull io.micronaut.core.type.Argument<? extends T> type) throws java.io.IOException
Encoder
.encoder
- The encoder to usecontext
- The encoder context, never null
value
- The value, can be null
type
- Models the generic type of the valuejava.io.IOException
- If an error occurs during serializationdefault boolean isEmpty(@Nullable T value)
JsonInclude.Include#NON_EMPTY
checking.value
- The check to checktrue
if the value is emptydefault boolean isAbsent(T value)
JsonInclude.Include#NON_ABSENT
checking.value
- The value to checktrue
if the value is absent