Class KotlinSerializationBinaryEncoder<T extends kotlinx.serialization.BinaryFormat>
java.lang.Object
org.springframework.http.codec.KotlinSerializationSupport<T>
org.springframework.http.codec.KotlinSerializationBinaryEncoder<T>
- Type Parameters:
T- the type ofBinaryFormat
- All Implemented Interfaces:
org.springframework.core.codec.Encoder<Object>
- Direct Known Subclasses:
KotlinSerializationCborEncoder, KotlinSerializationProtobufEncoder
public abstract class KotlinSerializationBinaryEncoder<T extends kotlinx.serialization.BinaryFormat>
extends KotlinSerializationSupport<T>
implements org.springframework.core.codec.Encoder<Object>
Abstract base class for
Encoder implementations that defer to Kotlin
binary serializers.
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 encoders 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
ConstructorsModifierConstructorDescriptionprotectedKotlinSerializationBinaryEncoder(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 encodes types for which the specified predicate returnstrue.protectedKotlinSerializationBinaryEncoder(T format, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only encodes types annotated with@Serializableat type or generics level. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanEncode(org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType) reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(Publisher<?> inputStream, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) org.springframework.core.io.buffer.DataBufferencodeValue(Object value, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType valueType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) List<org.springframework.util.MimeType> List<org.springframework.util.MimeType> getEncodableMimeTypes(org.springframework.core.ResolvableType elementType) Methods inherited from class KotlinSerializationSupport
canSerialize, format, serializer, supportedMimeTypes
-
Constructor Details
-
KotlinSerializationBinaryEncoder
protected KotlinSerializationBinaryEncoder(T format, org.springframework.util.MimeType... supportedMimeTypes) Creates a new instance with the given format and supported mime types which only encodes types annotated with@Serializableat type or generics level. -
KotlinSerializationBinaryEncoder
protected KotlinSerializationBinaryEncoder(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 encodes types for which the specified predicate returnstrue.- Since:
- 7.0
-
-
Method Details
-
canEncode
-
getEncodableMimeTypes
-
getEncodableMimeTypes
-
encode
public reactor.core.publisher.Flux<org.springframework.core.io.buffer.DataBuffer> encode(Publisher<?> inputStream, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType elementType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) - Specified by:
encodein interfaceorg.springframework.core.codec.Encoder<T extends kotlinx.serialization.BinaryFormat>
-
encodeValue
public org.springframework.core.io.buffer.DataBuffer encodeValue(Object value, org.springframework.core.io.buffer.DataBufferFactory bufferFactory, org.springframework.core.ResolvableType valueType, @Nullable org.springframework.util.MimeType mimeType, @Nullable Map<String, Object> hints) - Specified by:
encodeValuein interfaceorg.springframework.core.codec.Encoder<T extends kotlinx.serialization.BinaryFormat>
-