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.

Throws

INVALID_ARGUMENT if the type name is registered for another enum, or if T is registered under another type name or conventions.


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.

A type name is registered for one enum and an enum under one type name and one pair of conventions; the same enum under the same name with the same conventions again changes nothing.

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, if the type name is registered for another enum, or if enumClass is registered under another type name or conventions.