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

    • ByteArraySerde

      public ByteArraySerde(SerdeConfiguration serdeConfiguration)
    • 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 interface Serializer<byte[]>
      Parameters:
      context - The encoder context
      type - 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 interface Deserializer<byte[]>
      Parameters:
      context - The decoder context
      type - 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 the Decoder an object of type Deserializer.
      Specified by:
      deserialize in interface Deserializer<byte[]>
      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
    • 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 the Decoder an object of type Deserializer. If the decoder value is null, this must be permitted. By default, in this case, this method will return null.
      Specified by:
      deserializeNullable in interface Deserializer<byte[]>
      Parameters:
      decoder - The decoder, never null
      context - The decoder context, never null
      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 passed Encoder.
      Specified by:
      serialize in interface Serializer<byte[]>
      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

      public boolean isEmpty(Serializer.EncoderContext context, byte[] value)
      Description copied from interface: Serializer
      Used for JsonInclude.Include#NON_EMPTY checking.
      Specified by:
      isEmpty in interface Serializer<byte[]>
      Parameters:
      context - The encoder context
      value - The check to check
      Returns:
      Return true if the value is empty