EnumParameterConverter

internal class EnumParameterConverter<T : Enum<T>>(enumClass: KClass<T>, qualifiedName: QualifiedName, pgConvention: CaseConvention, kotlinConvention: CaseConvention) : ParameterConverter<T>

Converts a Kotlin Enum instance to its PostgreSQL String representation during query parameter serialization.

The two conventions describe the same constant on either side of the wire, and the mapping is applied name by name: a constant is read under kotlinConvention and written under pgConvention. Registering through registerEnum supplies CaseConvention.SNAKE_CASE_UPPER and CaseConvention.PASCAL_CASE respectively.

Type Parameters

T

The type of the Kotlin enum.

Constructors

Link copied to clipboard
constructor(enumClass: KClass<T>, qualifiedName: QualifiedName, pgConvention: CaseConvention, kotlinConvention: CaseConvention)

Properties

Link copied to clipboard
open override val supportedClass: KClass<T>

The Kotlin class this converter handles. The default canConvert also accepts its subtypes.

Functions

Link copied to clipboard
open fun canConvert(sourceClass: KClass<*>, expectedOid: Int, context: SerializationContext): Boolean

Decides whether this converter handles the value at hand.

Link copied to clipboard
open override fun convert(source: T, expectedOid: Int, context: SerializationContext): Any

Converts a value this converter has claimed into something a codec can encode.

Link copied to clipboard
open override fun getDefaultTypeName(sourceClass: KClass<*>, context: SerializationContext): QualifiedName

Names the PostgreSQL type to declare for the converted value, where nothing else has named one.