Package org.springframework.http.codec

# Class KotlinSerializationSupport<T extends kotlinx.serialization.SerialFormat>

java.lang.Object
org.springframework.http.codec.KotlinSerializationSupport<T>

Type Parameters:
  `T` - the type of `SerialFormat`

Direct Known Subclasses:
  `KotlinSerializationBinaryDecoder`, `KotlinSerializationBinaryEncoder`, `KotlinSerializationStringDecoder`, `KotlinSerializationStringEncoder`

public abstract class KotlinSerializationSupport<T extends kotlinx.serialization.SerialFormat> extends Object
Base class providing support methods for encoding and decoding with Kotlin serialization.

Since:
  6.0
Author:
  Sebastien Deleuze, Iain Henderson, Arjen Poutsma

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`KotlinSerializationSupport(T format, org.springframework.util.MimeType... supportedMimeTypes)`
Creates a new instance of this support class with the given format and supported mime types.

## Method Summary

Modifier and Type
Method
Description
`protected final boolean`
`canSerialize(org.springframework.core.ResolvableType type, org.springframework.util.MimeType mimeType)`
Indicates whether the given type can be serialized using Kotlin serialization.
`protected final T`
`format()`
Returns the format.
`protected final kotlinx.serialization.KSerializer<Object>`
`serializer(org.springframework.core.ResolvableType resolvableType)`
Returns the serializer that can (de)serialize instances of the given type.
`protected final List<org.springframework.util.MimeType>`
`supportedMimeTypes()`
Returns the supported mime types.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### KotlinSerializationSupport

protected KotlinSerializationSupport(T format, org.springframework.util.MimeType... supportedMimeTypes)
Creates a new instance of this support class with the given format and supported mime types.

## Method Details

### format

protected final T format()
Returns the format.

### supportedMimeTypes

protected final List<org.springframework.util.MimeType> supportedMimeTypes()
Returns the supported mime types.

### canSerialize

protected final boolean canSerialize(org.springframework.core.ResolvableType type, @Nullable org.springframework.util.MimeType mimeType)
Indicates whether the given type can be serialized using Kotlin serialization.

Parameters:
  `type` - the type to be serialized
  `mimeType` - the mimetype to use (can be `null`)
Returns:
  `true` if `type` can be serialized; false otherwise

### serializer

@Nullable protected final kotlinx.serialization.KSerializer<Object> serializer(org.springframework.core.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` - the type to find a serializer for
Returns:
  a resolved serializer for the given type, or `null`