Class KotlinSerializationCborEncoder
java.lang.Object
org.springframework.http.codec.KotlinSerializationSupport<kotlinx.serialization.cbor.Cbor>
org.springframework.http.codec.KotlinSerializationBinaryEncoder<kotlinx.serialization.cbor.Cbor>
org.springframework.http.codec.cbor.KotlinSerializationCborEncoder
public class KotlinSerializationCborEncoder
extends KotlinSerializationBinaryEncoder<kotlinx.serialization.cbor.Cbor>
Encode from an
Object stream to a byte stream of CBOR objects using
kotlinx.serialization.
It supports application/cbor.
As of Spring Framework 7.0, by default it only encodes types annotated with
@Serializable at type or generics
level since it allows combined usage with other general purpose JSON encoders
like JacksonCborEncoder without conflicts.
Alternative constructors with a Predicate<ResolvableType>
parameter can be used to customize this behavior. For example,
new KotlinSerializationCborEncoder(type -> true) will encode all types
supported by Kotlin Serialization, including unannotated Kotlin enumerations,
numbers, characters, booleans and strings.
- Since:
- 6.0
- Author:
- Iain Henderson, Sebastien Deleuze
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new encoder usingCbor.Defaultinstance which only encodes types annotated with@Serializableat type or generics level.KotlinSerializationCborEncoder(Predicate<ResolvableType> typePredicate) Construct a new encoder usingCbor.Defaultinstance which only encodes types for which the specified predicate returnstrue.KotlinSerializationCborEncoder(kotlinx.serialization.cbor.Cbor cbor) Construct a new encoder using the providedCborinstance which only encodes types annotated with@Serializableat type or generics level.KotlinSerializationCborEncoder(kotlinx.serialization.cbor.Cbor cbor, Predicate<ResolvableType> typePredicate) Construct a new encoder using the providedCborinstance which only encodes types for which the specified predicate returnstrue. -
Method Summary
Methods inherited from class KotlinSerializationBinaryEncoder
canEncode, encode, encodeValue, getEncodableMimeTypes, getEncodableMimeTypesMethods inherited from class KotlinSerializationSupport
canSerialize, format, serializer, supportedMimeTypes
-
Constructor Details
-
KotlinSerializationCborEncoder
public KotlinSerializationCborEncoder()Construct a new encoder usingCbor.Defaultinstance which only encodes types annotated with@Serializableat type or generics level. -
KotlinSerializationCborEncoder
Construct a new encoder usingCbor.Defaultinstance which only encodes types for which the specified predicate returnstrue.- Since:
- 7.0
-
KotlinSerializationCborEncoder
public KotlinSerializationCborEncoder(kotlinx.serialization.cbor.Cbor cbor) Construct a new encoder using the providedCborinstance which only encodes types annotated with@Serializableat type or generics level. -
KotlinSerializationCborEncoder
public KotlinSerializationCborEncoder(kotlinx.serialization.cbor.Cbor cbor, Predicate<ResolvableType> typePredicate) Construct a new encoder using the providedCborinstance which only encodes types for which the specified predicate returnstrue.- Since:
- 7.0
-