Top Description Fields Constructors Methods
org.springframework.http.codec

public abstract Class KotlinSerializationSupport<T extends kotlinx.serialization.SerialFormat>

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.http.codec.KotlinSerializationBinaryDecoder, org.springframework.http.codec.KotlinSerializationBinaryEncoder, org.springframework.http.codec.KotlinSerializationStringDecoder, org.springframework.http.codec.KotlinSerializationStringEncoder
Type Parameters
<T>
the type of SerialFormat
Imports
java.lang.reflect.Type, java.util.Arrays, .HashSet, .List, .Map, .Set, kotlinx.serialization.KSerializer, kotlinx.serialization.SerialFormat, kotlinx.serialization.SerializersKt, kotlinx.serialization.descriptors.PolymorphicKind, kotlinx.serialization.descriptors.SerialDescriptor, org.springframework.core.ResolvableType, org.springframework.lang.Nullable, org.springframework.util.ConcurrentReferenceHashMap, .MimeType

Base class providing support methods for encoding and decoding with Kotlin serialization.
Authors
Sebastien Deleuze, Iain Henderson, Arjen Poutsma
Since
6.0

Field Summary

Modifier and TypeField and Description
private final T
private final Map<Type, kotlinx.serialization.KSerializer<Object>>
private final List<MimeType>

Constructor Summary

AccessConstructor and Description
protected
KotlinSerializationSupport(T format, MimeType... supportedMimeTypes)

Creates a new instance of this support class with the given format and supported mime types.

Method Summary

Modifier and TypeMethod and Description
protected final boolean

Returns:

true if type can be serialized; false otherwise
canSerialize
(ResolvableType
the type to be serialized
type
,
MimeType
the mimetype to use (can be null)
mimeType
)

Indicates whether the given type can be serialized using Kotlin serialization.

protected final T
format()

Returns the format.

private static boolean
hasPolymorphism(kotlinx.serialization.descriptors.SerialDescriptor descriptor, Set<String> alreadyProcessed)

protected final kotlinx.serialization.KSerializer<Object>

Returns:

a resolved serializer for the given type, or null
serializer
(ResolvableType
the type to find a serializer for
resolvableType
)

Returns the serializer that can (de)serialize instances of the given type.

protected final List<MimeType>
supportedMimeTypes()

Returns the supported mime types.

private boolean
supports(MimeType mimeType)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

formatback to summary
private final T format
serializerCacheback to summary
private final Map<Type, kotlinx.serialization.KSerializer<Object>> serializerCache
supportedMimeTypesback to summary
private final List<MimeType> supportedMimeTypes

Constructor Detail

KotlinSerializationSupportback to summary
protected KotlinSerializationSupport(T format, MimeType... supportedMimeTypes)

Creates a new instance of this support class with the given format and supported mime types.

Method Detail

canSerializeback to summary
protected final boolean canSerialize(ResolvableType type, MimeType mimeType)

Indicates whether the given type can be serialized using Kotlin serialization.

Parameters
type:ResolvableType

the type to be serialized

mimeType:MimeType

the mimetype to use (can be null)

Returns:boolean

true if type can be serialized; false otherwise

formatback to summary
protected final T format()

Returns the format.

hasPolymorphismback to summary
private static boolean hasPolymorphism(kotlinx.serialization.descriptors.SerialDescriptor descriptor, Set<String> alreadyProcessed)
serializerback to summary
protected final kotlinx.serialization.KSerializer<Object> serializer(ResolvableType resolvableType)

Returns the serializer that can (de)serialize instances of the given type. If no serializer can be found, or if resolvableType is a open polymorphic type, null is returned.

Parameters
resolvableType:ResolvableType

the type to find a serializer for

Returns:kotlinx.serialization.KSerializer<Object>

a resolved serializer for the given type, or null

Annotations
@Nullable
supportedMimeTypesback to summary
protected final List<MimeType> supportedMimeTypes()

Returns the supported mime types.

supportsback to summary
private boolean supports(MimeType mimeType)