EnumResultConverter

internal class EnumResultConverter<T : Enum<T>>(enumClass: KClass<T>, qualifiedName: QualifiedName, pgConvention: CaseConvention, kotlinConvention: CaseConvention) : ResultConverter<String, T>

Converts a PostgreSQL String representation back into a Kotlin Enum instance during result set deserialization.

Claims a value only when the column's own type is the PostgreSQL enum named by qualifiedName, so an unrelated text column carrying the same label is left to another converter.

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 supportedSourceClass: KClass<String>

The decoded class this converter is indexed under. Use Any::class to be offered every value.

Functions

Link copied to clipboard
open override fun canConvert(sourceClass: KClass<*>, expectedType: KType, sourceType: PgType, context: DeserializationContext): Boolean

Decides whether this converter handles the value at hand. Must return false unless convert can produce an instance of expectedType.

Link copied to clipboard
open override fun convert(source: String, expectedType: KType, sourceType: PgType, context: DeserializationContext): T

Converts a value this converter has claimed.