registerEnum

inline fun <T : Enum<T>> registerEnum(typeName: String = "", schema: String = "", pgConvention: CaseConvention = CaseConvention.SNAKE_CASE_UPPER, kotlinConvention: CaseConvention = CaseConvention.PASCAL_CASE)

Registers an enum type, creating both parameter and result converters.

Parameters

typeName

Optional custom type name in the database.

schema

Optional schema where the enum is defined.

pgConvention

The naming convention used for enum values in PostgreSQL.

kotlinConvention

The naming convention used for enum values in Kotlin.

Type Parameters

T

The Kotlin enum class.


fun registerEnum(enumClass: KClass<*>, typeName: String = "", schema: String = "", pgConvention: CaseConvention = CaseConvention.SNAKE_CASE_UPPER, kotlinConvention: CaseConvention = CaseConvention.PASCAL_CASE)

Registers an enum type, creating both parameter and result converters.

Takes a plain KClass rather than one bound to Enum<T>, because the callers that reach this overload rather than the reified one are holding a class they found - a classpath scan, a configuration file - and cannot name its type. The bound bought them nothing but a cast at every call site; being an enum is checked here instead, once, and reported as the bad argument it is.

Parameters

enumClass

The Kotlin enum class.

typeName

Optional custom type name in the database.

schema

Optional schema where the enum is defined.

pgConvention

The naming convention used for enum values in PostgreSQL.

kotlinConvention

The naming convention used for enum values in Kotlin.

Throws

INVALID_ARGUMENT if enumClass is not an enum class.