Class NdJsonStringMediaTypeConverter

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

public class NdJsonStringMediaTypeConverter extends Object implements MediaTypeConverter<String>

String application/x-ndjson media type converter as defined by Newline Delimited JSON.

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

    • NdJsonStringMediaTypeConverter

      public NdJsonStringMediaTypeConverter(ReactiveConverter<String,Object> jsonStringConverter)

      Creates an application/x-ndjson media type converter.

      Parameters:
      jsonStringConverter - the underlying JSON String converter
  • Method Details

    • canConvert

      public boolean canConvert(String mediaType)
      Description copied from interface: MediaTypeConverter

      Determines whether the converter can convert the specified media type.

      Specified by:
      canConvert in interface MediaTypeConverter<String>
      Parameters:
      mediaType - a media type
      Returns:
      true if the converter can convert the media type, false otherwise
    • 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
    • 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
    • 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
    • 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