Class JacksonByteBufConverter

java.lang.Object
io.inverno.mod.boot.converter.JacksonByteBufConverter
All Implemented Interfaces:
Converter<ByteBuf,Object>, Decoder<ByteBuf,Object>, Encoder<Object,ByteBuf>, JoinableEncoder<Object,ByteBuf>, ReactiveConverter<ByteBuf,Object>, ReactiveDecoder<ByteBuf,Object>, ReactiveEncoder<Object,ByteBuf>, SplittableDecoder<ByteBuf,Object>

public class JacksonByteBufConverter extends Object implements ReactiveConverter<ByteBuf,Object>, SplittableDecoder<ByteBuf,Object>, JoinableEncoder<Object,ByteBuf>

JSON Bytebuf to Object converter backed by an ObjectMapper.

Since:
1.0
Author:
Jeremy Kuhn
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    JacksonByteBufConverter(com.fasterxml.jackson.databind.ObjectMapper mapper)
    Creates a JSON ByteBuf converter.
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    decode(ByteBuf value, Class<T> type)
    Decodes the specified value to an object whose type is represented by the specified class.
    <T> T
    decode(ByteBuf value, Type type)
    Decodes the specified value to an object of the specified type.
    <T> Flux<T>
    decodeMany(Publisher<ByteBuf> value, Class<T> type)
    Decodes the specified stream of values whose type is represented by the specified class into a flux stream of values.
    <T> Flux<T>
    Decodes the specified stream of values whose type is the specified type into a flux stream of values.
    <T> Mono<T>
    decodeOne(Publisher<ByteBuf> value, Class<T> type)
    Decodes the specified stream of values whose type is represented by the specified class into a mono stream of values.
    <T> Mono<T>
    Decodes the specified stream of values whose type is the specified type into a mono stream of value.
    <T> T[]
    decodeToArray(ByteBuf value, Class<T> type)
    Decodes the specified value whose type is represented by the specified class to an array of decoded values.
    <T> T[]
    decodeToArray(ByteBuf value, Type type)
    Decodes the specified value whose type is the specified type to an array of decoded values.
    <T> List<T>
    decodeToList(ByteBuf value, Class<T> type)
    Decodes the specified value whose type is represented by the specified class to a list of decoded values.
    <T> List<T>
    decodeToList(ByteBuf value, Type type)
    Decodes the specified value whose type is the specified type to a list of decoded values.
    <T> Set<T>
    decodeToSet(ByteBuf value, Class<T> type)
    Decodes the specified value whose type is represented by the specified class to a set of decoded values.
    <T> Set<T>
    decodeToSet(ByteBuf value, Type type)
    Decodes the specified value whose type is the specified type to a set of decoded values.
    encode(Object value)
    Encodes the specified value to the encoded type.
    <T> ByteBuf
    encode(T value, Class<T> type)
    Encodes the specified value whose type is represented by the specified class to the encoded type.
    <T> ByteBuf
    encode(T value, Type type)
    Encodes the specified value whose type is the specified type to the encoded type.
    <T> ByteBuf
    encodeArray(T[] value)
    Encodes the specified array of values to the encoded type.
    <T> ByteBuf
    encodeArray(T[] value, Class<T> type)
    Encodes the specified array of values whose type is represented by the specified class to the encoded type.
    <T> ByteBuf
    encodeArray(T[] value, Type type)
    Encodes the specified array of values whose type is represented by the specified class to the encoded type.
    <T> ByteBuf
    encodeList(List<T> value)
    Encodes the specified list of values to an encoded value.
    <T> ByteBuf
    encodeList(List<T> value, Class<T> type)
    Encodes the specified list of values whose type is represented by the specified class to an encoded value.
    <T> ByteBuf
    encodeList(List<T> value, Type type)
    Encodes the specified list of values whose type is the specified type to an encoded value.
    encodeMany(Flux<T> value)
    Encodes a flux stream of values to a stream of values.
    encodeMany(Flux<T> value, Class<T> type)
    Encodes a flux stream of values whose type is represented by the specified class to a stream of values.
    encodeMany(Flux<T> value, Type type)
    Encodes a flux stream of values whose type is the specified type to a stream of values.
    encodeOne(Mono<T> value)
    Encodes a mono stream of values to a stream of values.
    encodeOne(Mono<T> value, Class<T> type)
    Encodes a mono stream of values whose type is represented by the specified class to a stream of values.
    encodeOne(Mono<T> value, Type type)
    Encodes a mono stream of values whose type is the specified type to a stream of values.
    <T> ByteBuf
    encodeSet(Set<T> value)
    Encodes the specified set of values to an encoded value.
    <T> ByteBuf
    encodeSet(Set<T> value, Class<T> type)
    Encodes the specified set of values whose type is represented by the specified class to an encoded value.
    <T> ByteBuf
    encodeSet(Set<T> value, Type type)
    Encodes the specified set of values whose type is the specified type to an encoded value.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JacksonByteBufConverter

      public JacksonByteBufConverter(com.fasterxml.jackson.databind.ObjectMapper mapper)

      Creates a JSON ByteBuf converter.

      Parameters:
      mapper - a Jackson object mapper
  • Method Details

    • encodeOne

      public <T> Publisher<ByteBuf> encodeOne(Mono<T> value)
      Description copied from interface: ReactiveEncoder

      Encodes a mono stream of values to a stream of values.

      Specified by:
      encodeOne in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the mono stream of values to encode
      Returns:
      a stream of encoded values
    • encodeOne

      public <T> Publisher<ByteBuf> encodeOne(Mono<T> value, Class<T> type)
      Description copied from interface: ReactiveEncoder

      Encodes a mono stream of values whose type is represented by the specified class to a stream of values.

      Specified by:
      encodeOne in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the mono stream of values to encode
      type - the class of the decoded object
      Returns:
      a stream of encoded values
    • encodeOne

      public <T> Publisher<ByteBuf> encodeOne(Mono<T> value, Type type)
      Description copied from interface: ReactiveEncoder

      Encodes a mono stream of values whose type is the specified type to a stream of values.

      Specified by:
      encodeOne in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the mono stream of values to encode
      type - the type of the decoded object
      Returns:
      a stream of encoded values
    • encodeMany

      public <T> Publisher<ByteBuf> encodeMany(Flux<T> value)
      Description copied from interface: ReactiveEncoder

      Encodes a flux stream of values to a stream of values.

      Specified by:
      encodeMany in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the flux stream of values to encode
      Returns:
      a stream of encoded values
    • encodeMany

      public <T> Publisher<ByteBuf> encodeMany(Flux<T> value, Class<T> type)
      Description copied from interface: ReactiveEncoder

      Encodes a flux stream of values whose type is represented by the specified class to a stream of values.

      Specified by:
      encodeMany in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the flux stream of values to encode
      type - the class of the decoded object
      Returns:
      a stream of encoded values
    • encodeMany

      public <T> Publisher<ByteBuf> encodeMany(Flux<T> value, Type type)
      Description copied from interface: ReactiveEncoder

      Encodes a flux stream of values whose type is the specified type to a stream of values.

      Specified by:
      encodeMany in interface ReactiveEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the flux stream of values to encode
      type - the type of the decoded object
      Returns:
      a stream of encoded values
    • encode

      public ByteBuf encode(Object value)
      Description copied from interface: Encoder

      Encodes the specified value to the encoded type.

      Specified by:
      encode in interface Encoder<Object,ByteBuf>
      Parameters:
      value - the object to encode
      Returns:
      an encoded object
    • encode

      public <T> ByteBuf encode(T value, Class<T> type) throws ConverterException
      Description copied from interface: Encoder

      Encodes the specified value whose type is represented by the specified class to the encoded type.

      Specified by:
      encode in interface Encoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the object to encode
      type - the class of the decoded object
      Returns:
      an encoded object
      Throws:
      ConverterException - if there was an error encoding the value
    • encode

      public <T> ByteBuf encode(T value, Type type) throws ConverterException
      Description copied from interface: Encoder

      Encodes the specified value whose type is the specified type to the encoded type.

      Specified by:
      encode in interface Encoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the object to encode
      type - the type of the decoded object
      Returns:
      an encoded object
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeList

      public <T> ByteBuf encodeList(List<T> value)
      Description copied from interface: JoinableEncoder

      Encodes the specified list of values to an encoded value.

      Specified by:
      encodeList in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the list of objects to encode
      Returns:
      an encoded value
    • encodeList

      public <T> ByteBuf encodeList(List<T> value, Class<T> type)
      Description copied from interface: JoinableEncoder

      Encodes the specified list of values whose type is represented by the specified class to an encoded value.

      Specified by:
      encodeList in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the list of objects to encode
      type - the class of the decoded object
      Returns:
      an encoded value
    • encodeList

      public <T> ByteBuf encodeList(List<T> value, Type type)
      Description copied from interface: JoinableEncoder

      Encodes the specified list of values whose type is the specified type to an encoded value.

      Specified by:
      encodeList in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the list of objects to encode
      type - the type of the decoded object
      Returns:
      an encoded value
    • encodeSet

      public <T> ByteBuf encodeSet(Set<T> value)
      Description copied from interface: JoinableEncoder

      Encodes the specified set of values to an encoded value.

      Specified by:
      encodeSet in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the set of objects to encode
      Returns:
      an encoded value
    • encodeSet

      public <T> ByteBuf encodeSet(Set<T> value, Class<T> type)
      Description copied from interface: JoinableEncoder

      Encodes the specified set of values whose type is represented by the specified class to an encoded value.

      Specified by:
      encodeSet in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the set of objects to encode
      type - the class of the decoded object
      Returns:
      an encoded value
    • encodeSet

      public <T> ByteBuf encodeSet(Set<T> value, Type type)
      Description copied from interface: JoinableEncoder

      Encodes the specified set of values whose type is the specified type to an encoded value.

      Specified by:
      encodeSet in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the set of objects to encode
      type - the type of the decoded object
      Returns:
      an encoded value
    • encodeArray

      public <T> ByteBuf encodeArray(T[] value)
      Description copied from interface: JoinableEncoder

      Encodes the specified array of values to the encoded type.

      Specified by:
      encodeArray in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the array of objects to encode
      Returns:
      an encoded value
    • encodeArray

      public <T> ByteBuf encodeArray(T[] value, Class<T> type)
      Description copied from interface: JoinableEncoder

      Encodes the specified array of values whose type is represented by the specified class to the encoded type.

      Specified by:
      encodeArray in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the array of objects to encode
      type - the class of the decoded object
      Returns:
      an encoded value
    • encodeArray

      public <T> ByteBuf encodeArray(T[] value, Type type)
      Description copied from interface: JoinableEncoder

      Encodes the specified array of values whose type is represented by the specified class to the encoded type.

      Specified by:
      encodeArray in interface JoinableEncoder<Object,ByteBuf>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the array of objects to encode
      type - the class of the decoded object
      Returns:
      an encoded value
    • decodeOne

      public <T> Mono<T> decodeOne(Publisher<ByteBuf> value, Class<T> type)
      Description copied from interface: ReactiveDecoder

      Decodes the specified stream of values whose type is represented by the specified class into a mono stream of values.

      Specified by:
      decodeOne in interface ReactiveDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the stream of values to decode
      type - the class of the decoded object
      Returns:
      a mono emitting the decoded value
    • decodeOne

      public <T> Mono<T> decodeOne(Publisher<ByteBuf> value, Type type)
      Description copied from interface: ReactiveDecoder

      Decodes the specified stream of values whose type is the specified type into a mono stream of value.

      Specified by:
      decodeOne in interface ReactiveDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the stream of values to decode
      type - the type of the decoded object
      Returns:
      a mono emitting the decoded value
    • decodeMany

      public <T> Flux<T> decodeMany(Publisher<ByteBuf> value, Class<T> type)
      Description copied from interface: ReactiveDecoder

      Decodes the specified stream of values whose type is represented by the specified class into a flux stream of values.

      Specified by:
      decodeMany in interface ReactiveDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the stream of values to decode
      type - the class of the decoded object
      Returns:
      a flux emitting the decoded values
    • decodeMany

      public <T> Flux<T> decodeMany(Publisher<ByteBuf> value, Type type)
      Description copied from interface: ReactiveDecoder

      Decodes the specified stream of values whose type is the specified type into a flux stream of values.

      Specified by:
      decodeMany in interface ReactiveDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the stream of values to decode
      type - the type of the decoded object
      Returns:
      a flux emitting the decoded values
    • decode

      public <T> T decode(ByteBuf value, Class<T> type)
      Description copied from interface: Decoder

      Decodes the specified value to an object whose type is represented by the specified class.

      Specified by:
      decode in interface Decoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the object to decode
      type - the class of the decoded object
      Returns:
      a decoded object
    • decode

      public <T> T decode(ByteBuf value, Type type) throws ConverterException
      Description copied from interface: Decoder

      Decodes the specified value to an object of the specified type.

      Specified by:
      decode in interface Decoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the object to decode
      type - the type of the decoded object
      Returns:
      a decoded object
      Throws:
      ConverterException - if there was an error decoding the value
    • decodeToList

      public <T> List<T> decodeToList(ByteBuf value, Class<T> type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is represented by the specified class to a list of decoded values.

      Specified by:
      decodeToList in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the class of the decoded object
      Returns:
      a list of decoded values
    • decodeToList

      public <T> List<T> decodeToList(ByteBuf value, Type type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is the specified type to a list of decoded values.

      Specified by:
      decodeToList in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the type of the decoded object
      Returns:
      a list of decoded values
    • decodeToSet

      public <T> Set<T> decodeToSet(ByteBuf value, Class<T> type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is represented by the specified class to a set of decoded values.

      Specified by:
      decodeToSet in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the class of the decoded object
      Returns:
      a set of decoded values
    • decodeToSet

      public <T> Set<T> decodeToSet(ByteBuf value, Type type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is the specified type to a set of decoded values.

      Specified by:
      decodeToSet in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the type of the decoded object
      Returns:
      a set of decoded values
    • decodeToArray

      public <T> T[] decodeToArray(ByteBuf value, Class<T> type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is represented by the specified class to an array of decoded values.

      Specified by:
      decodeToArray in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the class of the decoded object
      Returns:
      an array of decoded values
    • decodeToArray

      public <T> T[] decodeToArray(ByteBuf value, Type type)
      Description copied from interface: SplittableDecoder

      Decodes the specified value whose type is the specified type to an array of decoded values.

      Specified by:
      decodeToArray in interface SplittableDecoder<ByteBuf,Object>
      Type Parameters:
      T - the type of the decoded object
      Parameters:
      value - the value to decode
      type - the type of the decoded object
      Returns:
      an array of decoded values