Class JacksonStringConverter

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

public class JacksonStringConverter extends Object implements ReactiveConverter<String,Object>, SplittableDecoder<String,Object>, JoinableEncoder<Object,String>

JSON String to Object converter backed by an ObjectMapper.

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

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

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

    • JacksonStringConverter

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

      Creates a JSON String converter.

      Parameters:
      mapper - a Jackson object mapper
  • Method Details

    • encodeOne

      public <T> Publisher<String> 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,String>
      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<String> 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,String>
      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<String> 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,String>
      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<String> 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,String>
      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<String> 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,String>
      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<String> 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,String>
      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 <T> String encode(T value) throws ConverterException
      Description copied from interface: Encoder

      Encodes the specified value to the encoded type.

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

      public <T> String 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,String>
      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> String 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,String>
      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> String encodeList(List<T> value) throws ConverterException
      Description copied from interface: JoinableEncoder

      Encodes the specified list of values to an encoded value.

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

      public <T> String encodeList(List<T> value, Class<T> type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeList

      public <T> String encodeList(List<T> value, Type type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeSet

      public <T> String encodeSet(Set<T> value) throws ConverterException
      Description copied from interface: JoinableEncoder

      Encodes the specified set of values to an encoded value.

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

      public <T> String encodeSet(Set<T> value, Class<T> type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeSet

      public <T> String encodeSet(Set<T> value, Type type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeArray

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

      Encodes the specified array of values to the encoded type.

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

      public <T> String encodeArray(T[] value, Class<T> type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • encodeArray

      public <T> String encodeArray(T[] value, Type type) throws ConverterException
      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,String>
      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
      Throws:
      ConverterException - if there was an error encoding the value
    • decodeOne

      public <T> Mono<T> decodeOne(Publisher<String> 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<String,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<String> 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<String,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<String> 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<String,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<String> 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<String,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(String value, Class<T> type) throws ConverterException
      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<String,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
      Throws:
      ConverterException - if there was an error decoding the value
    • decode

      public <T> T decode(String 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<String,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(String 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<String,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(String 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<String,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(String 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<String,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(String 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<String,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(String 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<String,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(String 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<String,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