Class KotlinSerializationCborDecoder
java.lang.Object
org.springframework.http.codec.KotlinSerializationSupport<kotlinx.serialization.cbor.Cbor>
org.springframework.http.codec.KotlinSerializationBinaryDecoder<kotlinx.serialization.cbor.Cbor>
org.springframework.http.codec.cbor.KotlinSerializationCborDecoder
- All Implemented Interfaces:
org.springframework.core.codec.Decoder<Object>
public class KotlinSerializationCborDecoder
extends KotlinSerializationBinaryDecoder<kotlinx.serialization.cbor.Cbor>
Decode a byte stream into CBOR and convert to Objects with
kotlinx.serialization.
It supports
application/cbor.
As of Spring Framework 7.0, by default it only decodes types annotated with
@Serializable at type or generics
level since it allows combined usage with other general purpose CBOR decoders
like JacksonCborDecoder without conflicts.
Alternative constructors with a Predicate<ResolvableType>
parameter can be used to customize this behavior. For example,
new KotlinSerializationCborDecoder(type -> true) will decode all types
supported by Kotlin Serialization, including unannotated Kotlin enumerations,
numbers, characters, booleans and strings.
Decoding streams is not supported yet, see kotlinx.serialization/issues/1073 related issue.
- Since:
- 6.0
- Author:
- Iain Henderson, Sebastien Deleuze
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new decoder usingCbor.Defaultinstance which only decodes types annotated with@Serializableat type or generics level.KotlinSerializationCborDecoder(Predicate<org.springframework.core.ResolvableType> typePredicate) Construct a new decoder usingCbor.Defaultinstance which only decodes types for which the specified predicate returnstrue.KotlinSerializationCborDecoder(kotlinx.serialization.cbor.Cbor cbor) Construct a new decoder using the providedCborinstance which only decodes types annotated with@Serializableat type or generics level.KotlinSerializationCborDecoder(kotlinx.serialization.cbor.Cbor cbor, Predicate<org.springframework.core.ResolvableType> typePredicate) Construct a new decoder using the providedCborinstance which only decodes types for which the specified predicate returnstrue. -
Method Summary
Methods inherited from class KotlinSerializationBinaryDecoder
canDecode, decode, decodeToMono, getDecodableMimeTypes, getDecodableMimeTypes, getMaxInMemorySize, setMaxInMemorySizeMethods inherited from class KotlinSerializationSupport
canSerialize, format, serializer, supportedMimeTypesMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.core.codec.Decoder
decode
-
Constructor Details
-
KotlinSerializationCborDecoder
public KotlinSerializationCborDecoder()Construct a new decoder usingCbor.Defaultinstance which only decodes types annotated with@Serializableat type or generics level. -
KotlinSerializationCborDecoder
public KotlinSerializationCborDecoder(Predicate<org.springframework.core.ResolvableType> typePredicate) Construct a new decoder usingCbor.Defaultinstance which only decodes types for which the specified predicate returnstrue.- Since:
- 7.0
-
KotlinSerializationCborDecoder
public KotlinSerializationCborDecoder(kotlinx.serialization.cbor.Cbor cbor) Construct a new decoder using the providedCborinstance which only decodes types annotated with@Serializableat type or generics level. -
KotlinSerializationCborDecoder
public KotlinSerializationCborDecoder(kotlinx.serialization.cbor.Cbor cbor, Predicate<org.springframework.core.ResolvableType> typePredicate) Construct a new decoder using the providedCborinstance which only decodes types for which the specified predicate returnstrue.- Since:
- 7.0
-