← Back to Stormify Documentation

EnumRegistry

Registry for enum classes, used by native targets where reflection is not available. On JVM, enum operations use reflection directly and this registry is not needed. On native, the annotation processor generates calls to register at startup.

Functions

Link copied to clipboard
fun entriesOf(enumClass: KClass<*>): Array<out Enum<*>>?

Returns the registered enum constants for enumClass, or null if not registered.

Link copied to clipboard
fun <T : Any> fromInt(enumClass: KClass<T>, value: Int): T?

Returns the enum constant of enumClass whose integer value (ordinal or DbValue.dbValue) is value, or null if enumClass is not registered or no matching constant exists.

Link copied to clipboard
fun <T : Any> fromName(enumClass: KClass<T>, name: String): T?

Returns the enum constant of enumClass whose name is name (case-insensitive), or null if enumClass is not registered or no matching constant exists.

Link copied to clipboard
fun isRegistered(enumClass: KClass<*>): Boolean

Returns true if enumClass has been registered via register.

Link copied to clipboard
fun register(enumClass: KClass<*>, entries: Array<out Enum<*>>, toInt: (Any) -> Int)

Registers the enum constants and int encoder for the given enum class. Called by annproc-generated code at startup; user code normally does not invoke this directly. fromInt and fromName are derived from entries on each lookup.

Link copied to clipboard
fun toInt(value: Any): Int?

Returns the integer value (ordinal or DbValue.dbValue) for the given enum constant, or null if the constant's class has not been registered.