Class KotlinSerializationBinaryDecoder<T extends kotlinx.serialization.BinaryFormat>
java.lang.Object
org.springframework.http.codec.KotlinSerializationSupport<T>
org.springframework.http.codec.KotlinSerializationBinaryDecoder<T>
- Type Parameters:
T- the type ofBinaryFormat
- All Implemented Interfaces:
org.springframework.core.codec.Decoder<Object>
- Direct Known Subclasses:
KotlinSerializationCborDecoder, KotlinSerializationProtobufDecoder
public abstract class KotlinSerializationBinaryDecoder<T extends kotlinx.serialization.BinaryFormat>
extends KotlinSerializationSupport<T>
implements org.springframework.core.codec.Decoder<Object>
Abstract base class for
Decoder implementations that defer to Kotlin
binary serializers.
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 decoders without conflicts.
Alternative constructors with a Predicate<ResolvableType> parameter can be used
to customize this behavior.
- Since:
- 6.0
- Author:
- Sebastien Deleuze, Iain Henderson, Arjen Poutsma
-
Constructor Summary
ConstructorsConstructorDescriptionKotlinSerializationBinaryDecoder(T format, Predicate<org.springframework.core.ResolvableType> typePredicate, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only decodes types for which the specified predicate returnstrue.KotlinSerializationBinaryDecoder(T format, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only decodes types annotated with@Serializableat type or generics level. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecode(org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType) reactor.core.publisher.Flux<Object> decode(Publisher<org.springframework.core.io.buffer.DataBuffer> inputStream, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) reactor.core.publisher.Mono<Object> decodeToMono(Publisher<org.springframework.core.io.buffer.DataBuffer> inputStream, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) List<org.springframework.util.MimeType> List<org.springframework.util.MimeType> getDecodableMimeTypes(org.springframework.core.ResolvableType targetType) intReturn theconfiguredbyte count limit.voidsetMaxInMemorySize(int byteCount) Configure a limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated.Methods 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
-
KotlinSerializationBinaryDecoder
public KotlinSerializationBinaryDecoder(T format, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only decodes types annotated with@Serializableat type or generics level. -
KotlinSerializationBinaryDecoder
public KotlinSerializationBinaryDecoder(T format, Predicate<org.springframework.core.ResolvableType> typePredicate, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only decodes types for which the specified predicate returnstrue.- Since:
- 7.0
-
-
Method Details
-
setMaxInMemorySize
public void setMaxInMemorySize(int byteCount) Configure a limit on the number of bytes that can be buffered whenever the input stream needs to be aggregated. This can be a result of decoding to a singleDataBuffer,ByteBuffer,byte[],Resource,String, etc. It can also occur when splitting the input stream, for example, delimited text, in which case the limit applies to data buffered between delimiters.By default this is set to 256K.
- Parameters:
byteCount- the max number of bytes to buffer, or -1 for unlimited
-
getMaxInMemorySize
public int getMaxInMemorySize()Return theconfiguredbyte count limit. -
canDecode
-
getDecodableMimeTypes
-
getDecodableMimeTypes
-
decode
public reactor.core.publisher.Flux<Object> decode(Publisher<org.springframework.core.io.buffer.DataBuffer> inputStream, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) - Specified by:
decodein interfaceorg.springframework.core.codec.Decoder<T extends kotlinx.serialization.BinaryFormat>
-
decodeToMono
public reactor.core.publisher.Mono<Object> decodeToMono(Publisher<org.springframework.core.io.buffer.DataBuffer> inputStream, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) - Specified by:
decodeToMonoin interfaceorg.springframework.core.codec.Decoder<T extends kotlinx.serialization.BinaryFormat>
-