Class KotlinSerializationBinaryHttpMessageConverter<T extends kotlinx.serialization.BinaryFormat>
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
org.springframework.http.converter.AbstractSmartHttpMessageConverter<Object>
org.springframework.http.converter.AbstractKotlinSerializationHttpMessageConverter<T>
org.springframework.http.converter.KotlinSerializationBinaryHttpMessageConverter<T>
- Type Parameters:
T- the type ofBinaryFormat
- All Implemented Interfaces:
HttpMessageConverter<Object>, SmartHttpMessageConverter<Object>
- Direct Known Subclasses:
KotlinSerializationCborHttpMessageConverter, KotlinSerializationProtobufHttpMessageConverter
public abstract class KotlinSerializationBinaryHttpMessageConverter<T extends kotlinx.serialization.BinaryFormat>
extends AbstractKotlinSerializationHttpMessageConverter<T>
Abstract base class for
HttpMessageConverter 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 converters without conflicts.
Alternative constructors with a Predicate<ResolvableType> parameter can be used
to customize this behavior.
- Since:
- 6.0
- Author:
- Andreas Ahlenstorf, Sebastien Deleuze, Juergen Hoeller, Iain Henderson, Arjen Poutsma
-
Field Summary
Fields inherited from class AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedKotlinSerializationBinaryHttpMessageConverter(T format, Predicate<ResolvableType> typePredicate, MediaType... supportedMediaTypes) Creates a new instance with the given format and supported mime types which only converts types for which the specified predicate returnstrue.protectedKotlinSerializationBinaryHttpMessageConverter(T format, MediaType... supportedMediaTypes) Creates a new instance with the given format and supported mime types which only converters types annotated with@Serializableat type or generics level. -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectreadInternal(kotlinx.serialization.KSerializer<Object> serializer, T format, HttpInputMessage inputMessage) Reads the given input message with the given serializer and format.protected voidwriteInternal(Object object, kotlinx.serialization.KSerializer<Object> serializer, T format, HttpOutputMessage outputMessage) Write the given object to the output message with the given serializer and format.Methods inherited from class AbstractKotlinSerializationHttpMessageConverter
canRead, canWrite, getSupportedMediaTypes, read, supports, supportsRepeatableWrites, writeInternalMethods inherited from class AbstractSmartHttpMessageConverter
readInternal, write, writeInternalMethods inherited from class AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, 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
canRead, canWrite, read, write
-
Constructor Details
-
KotlinSerializationBinaryHttpMessageConverter
-
KotlinSerializationBinaryHttpMessageConverter
protected KotlinSerializationBinaryHttpMessageConverter(T format, Predicate<ResolvableType> typePredicate, MediaType... supportedMediaTypes) Creates a new instance with the given format and supported mime types which only converts types for which the specified predicate returnstrue.- Since:
- 7.0
-
-
Method Details
-
readInternal
protected Object readInternal(kotlinx.serialization.KSerializer<Object> serializer, T format, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException Description copied from class:AbstractKotlinSerializationHttpMessageConverterReads the given input message with the given serializer and format.- Specified by:
readInternalin classAbstractKotlinSerializationHttpMessageConverter<T extends kotlinx.serialization.BinaryFormat>- Throws:
IOExceptionHttpMessageNotReadableException
-
writeInternal
protected void writeInternal(Object object, kotlinx.serialization.KSerializer<Object> serializer, T format, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException Description copied from class:AbstractKotlinSerializationHttpMessageConverterWrite the given object to the output message with the given serializer and format.- Specified by:
writeInternalin classAbstractKotlinSerializationHttpMessageConverter<T extends kotlinx.serialization.BinaryFormat>- Throws:
IOExceptionHttpMessageNotWritableException
-