Class KotlinSerializationCborHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
org.springframework.http.converter.AbstractSmartHttpMessageConverter<Object>
org.springframework.http.converter.AbstractKotlinSerializationHttpMessageConverter<kotlinx.serialization.cbor.Cbor>
org.springframework.http.converter.KotlinSerializationBinaryHttpMessageConverter<kotlinx.serialization.cbor.Cbor>
org.springframework.http.converter.cbor.KotlinSerializationCborHttpMessageConverter
- All Implemented Interfaces:
HttpMessageConverter<Object>, SmartHttpMessageConverter<Object>
public class KotlinSerializationCborHttpMessageConverter
extends KotlinSerializationBinaryHttpMessageConverter<kotlinx.serialization.cbor.Cbor>
Implementation of
HttpMessageConverter
that can read and write CBOR using
kotlinx.serialization.
It supports application/cbor.
As of Spring Framework 7.0, by default it only types annotated with
@Serializable at type or generics
level since it allows combined usage with other general purpose JSON decoders
like JacksonCborHttpMessageConverter without conflicts.
Alternative constructors with a Predicate<ResolvableType>
parameter can be used to customize this behavior. For example,
new KotlinSerializationCborHttpMessageConverter(type -> true) will decode all types
supported by Kotlin Serialization, including unannotated Kotlin enumerations,
numbers, characters, booleans and strings.
- Since:
- 6.0
- Author:
- Iain Henderson, Sebastien Deleuze
-
Field Summary
Fields inherited from class AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new converter usingCbor.Defaultinstance which only converts types annotated with@Serializableat type or generics level.KotlinSerializationCborHttpMessageConverter(Predicate<ResolvableType> typePredicate) Construct a new converter usingCbor.Defaultinstance which only converts types for which the specified predicate returnstrue.KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor) Construct a new converter using the providedCborinstance which only converts types annotated with@Serializableat type or generics level.KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor, Predicate<ResolvableType> typePredicate) Construct a new converter using the providedCborinstance which only converts types for which the specified predicate returnstrue. -
Method Summary
Methods inherited from class KotlinSerializationBinaryHttpMessageConverter
readInternal, writeInternalMethods inherited from class AbstractKotlinSerializationHttpMessageConverter
canRead, canWrite, getSupportedMediaTypes, read, supports, supportsRepeatableWrites, writeInternalMethods inherited from class AbstractSmartHttpMessageConverter
canRead, canWrite, readInternal, write, writeInternalMethods inherited from class AbstractHttpMessageConverter
addDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface HttpMessageConverter
getSupportedMediaTypesMethods inherited from interface SmartHttpMessageConverter
read, write
-
Constructor Details
-
KotlinSerializationCborHttpMessageConverter
public KotlinSerializationCborHttpMessageConverter()Construct a new converter usingCbor.Defaultinstance which only converts types annotated with@Serializableat type or generics level. -
KotlinSerializationCborHttpMessageConverter
Construct a new converter usingCbor.Defaultinstance which only converts types for which the specified predicate returnstrue.- Since:
- 7.0
-
KotlinSerializationCborHttpMessageConverter
public KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor) Construct a new converter using the providedCborinstance which only converts types annotated with@Serializableat type or generics level. -
KotlinSerializationCborHttpMessageConverter
public KotlinSerializationCborHttpMessageConverter(kotlinx.serialization.cbor.Cbor cbor, Predicate<ResolvableType> typePredicate) Construct a new converter using the providedCborinstance which only converts types for which the specified predicate returnstrue.- Since:
- 7.0
-