Class KotlinSerializationProtobufHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<Object>
org.springframework.http.converter.AbstractSmartHttpMessageConverter<Object>
org.springframework.http.converter.AbstractKotlinSerializationHttpMessageConverter<kotlinx.serialization.protobuf.ProtoBuf>
org.springframework.http.converter.KotlinSerializationBinaryHttpMessageConverter<kotlinx.serialization.protobuf.ProtoBuf>
org.springframework.http.converter.protobuf.KotlinSerializationProtobufHttpMessageConverter
- All Implemented Interfaces:
HttpMessageConverter<Object>, SmartHttpMessageConverter<Object>
public class KotlinSerializationProtobufHttpMessageConverter
extends KotlinSerializationBinaryHttpMessageConverter<kotlinx.serialization.protobuf.ProtoBuf>
Implementation of
HttpMessageConverter
that can read and write Protocol Buffers using
kotlinx.serialization.
It supports application/x-protobuf, application/octet-stream, and application/vnd.google.protobuf.
As of Spring Framework 7.0, by default it only converts types annotated with
@Serializable at type or generics
level.
Alternative constructors with a Predicate<ResolvableType>
parameter can be used to customize this behavior. For example,
new KotlinSerializationProtobufHttpMessageConverter(type -> true) will convert all types
supported by Kotlin Serialization, including unannotated Kotlin enumerations,
numbers, characters, booleans and strings.
- Since:
- 6.0
- Author:
- Iain Henderson, Sebstien Deleuze
-
Field Summary
Fields inherited from class AbstractHttpMessageConverter
logger -
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new converter usingProtoBuf.Defaultinstance which only converts types annotated with@Serializableat type or generics level.KotlinSerializationProtobufHttpMessageConverter(Predicate<ResolvableType> typePredicate) Construct a new converter usingProtoBuf.Defaultinstance which only converts types for which the specified predicate returnstrue.KotlinSerializationProtobufHttpMessageConverter(kotlinx.serialization.protobuf.ProtoBuf protobuf) Construct a new converter using the providedProtoBufinstance which only converts types annotated with@Serializableat type or generics level.KotlinSerializationProtobufHttpMessageConverter(kotlinx.serialization.protobuf.ProtoBuf protobuf, Predicate<ResolvableType> typePredicate) Construct a new converter using the providedProtoBufinstance which only converts types for which the specified predicate returnstrue. -
Method Summary
Methods inherited from class KotlinSerializationBinaryHttpMessageConverter
readInternal, writeInternalMethods 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
-
KotlinSerializationProtobufHttpMessageConverter
public KotlinSerializationProtobufHttpMessageConverter()Construct a new converter usingProtoBuf.Defaultinstance which only converts types annotated with@Serializableat type or generics level. -
KotlinSerializationProtobufHttpMessageConverter
Construct a new converter usingProtoBuf.Defaultinstance which only converts types for which the specified predicate returnstrue.- Since:
- 7.0
-
KotlinSerializationProtobufHttpMessageConverter
public KotlinSerializationProtobufHttpMessageConverter(kotlinx.serialization.protobuf.ProtoBuf protobuf) Construct a new converter using the providedProtoBufinstance which only converts types annotated with@Serializableat type or generics level. -
KotlinSerializationProtobufHttpMessageConverter
public KotlinSerializationProtobufHttpMessageConverter(kotlinx.serialization.protobuf.ProtoBuf protobuf, Predicate<ResolvableType> typePredicate) Construct a new converter using the providedProtoBufinstance which only converts types for which the specified predicate returnstrue.- Since:
- 7.0
-