Package io.micronaut.serde.support
Class DefaultSerdeRegistry.ByteArraySerde
java.lang.Object
io.micronaut.serde.support.DefaultSerdeRegistry.ByteArraySerde
- All Implemented Interfaces:
Deserializer<byte[]>
,Serde<byte[]>
,Serializer<byte[]>
- Enclosing class:
- DefaultSerdeRegistry
@Singleton
@Internal
public static final class DefaultSerdeRegistry.ByteArraySerde
extends Object
implements Serde<byte[]>
Serde for byte arrays. Nested class for binary compatibility.
-
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
-
Constructor Summary
ConstructorDescriptionByteArraySerde
(boolean writeLegacyByteArrays) ByteArraySerde
(SerdeConfiguration serdeConfiguration) -
Method Summary
Modifier and TypeMethodDescription@NonNull Deserializer<byte[]>
createSpecific
(@NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super byte[]> type) Create a new child deserializer or return this if non is necessary for the given context.@NonNull Serializer<byte[]>
createSpecific
(@NonNull Serializer.EncoderContext context, @NonNull io.micronaut.core.type.Argument<? extends byte[]> type) Create a more specific serializer for the given definition.byte[]
deserialize
(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super byte[]> type) Deserializes from the current state of theDecoder
an object of typeDeserializer
.byte[]
deserializeNullable
(@NonNull Decoder decoder, @NonNull Deserializer.DecoderContext context, @NonNull io.micronaut.core.type.Argument<? super byte[]> type) Deserializes from the current state of theDecoder
an object of typeDeserializer
.boolean
isEmpty
(Serializer.EncoderContext context, byte[] value) Used forJsonInclude.Include#NON_EMPTY
checking.void
serialize
(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends byte[]> type, byte[] 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, getDefaultValue
Methods inherited from interface io.micronaut.serde.Serializer
isAbsent
-
Constructor Details
-
ByteArraySerde
-
ByteArraySerde
@Internal public ByteArraySerde(boolean writeLegacyByteArrays)
-
-
Method Details
-
createSpecific
@NonNull public @NonNull Serializer<byte[]> createSpecific(@NonNull @NonNull Serializer.EncoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? extends byte[]> type) throws SerdeException Description copied from interface:Serializer
Create a more specific serializer for the given definition.- Specified by:
createSpecific
in interfaceSerializer<byte[]>
- Parameters:
context
- The encoder contexttype
- The type definition including any annotation metadata- Returns:
- The more specific serializer
- Throws:
SerdeException
-
createSpecific
@NonNull public @NonNull Deserializer<byte[]> createSpecific(@NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super byte[]> type) 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<byte[]>
- Parameters:
context
- The decoder contexttype
- 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
-
deserialize
public byte[] deserialize(Decoder decoder, Deserializer.DecoderContext decoderContext, io.micronaut.core.type.Argument<? super byte[]> type) throws IOException Description copied from interface:Deserializer
Deserializes from the current state of theDecoder
an object of typeDeserializer
.- Specified by:
deserialize
in interfaceDeserializer<byte[]>
- 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
-
deserializeNullable
public byte[] deserializeNullable(@NonNull @NonNull Decoder decoder, @NonNull @NonNull Deserializer.DecoderContext context, @NonNull @NonNull io.micronaut.core.type.Argument<? super byte[]> type) throws IOException Description copied from interface:Deserializer
Deserializes from the current state of theDecoder
an object of typeDeserializer
. If the decoder value isnull
, this must be permitted. By default, in this case, this method will returnnull
.- Specified by:
deserializeNullable
in interfaceDeserializer<byte[]>
- Parameters:
decoder
- The decoder, nevernull
context
- The decoder context, nevernull
type
- The generic type to be deserialized- Returns:
- The deserialized object or
null
- Throws:
IOException
- If an error occurs during deserialization of the object
-
serialize
public void serialize(Encoder encoder, Serializer.EncoderContext context, io.micronaut.core.type.Argument<? extends byte[]> type, byte[] value) throws IOException Description copied from interface:Serializer
Serializes the given value using the passedEncoder
.- Specified by:
serialize
in interfaceSerializer<byte[]>
- 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
-
isEmpty
Description copied from interface:Serializer
Used forJsonInclude.Include#NON_EMPTY
checking.- Specified by:
isEmpty
in interfaceSerializer<byte[]>
- Parameters:
context
- The encoder contextvalue
- The check to check- Returns:
- Return
true
if the value is empty
-