EnumValue

data class EnumValue<E : Enum<E>>(val value: E, val enumClass: KClass<E>) : TypedValue

Wrapper for an enum value with its type token.

Parameters

E

The enum type

Constructors

Link copied to clipboard
constructor(value: E, enumClass: KClass<E>)

Properties

Link copied to clipboard

The KClass type token for runtime type checking

Link copied to clipboard
open override val stringValue: String

String representation of the value. For enums, this is the enum's name property. For strings, this is the string itself.

Link copied to clipboard
val value: E

The actual enum instance

Functions

Link copied to clipboard

Returns the enum value if this is an EnumValue, null otherwise. The type is erased to Enum<*> since the actual type is not known at compile time.

Link copied to clipboard
inline fun <E : Enum<E>> getAs(): E?

Attempts to retrieve the value as the specified enum type.

fun <E : Enum<E>> getAs(kClass: KClass<E>): E?

Attempts to retrieve the value as the specified enum type using KClass.

Link copied to clipboard
inline fun <E : Enum<E>> isType(): Boolean

Checks if this value is of the specified enum type.

fun <E : Enum<E>> isType(kClass: KClass<E>): Boolean

Checks if this value is of the specified enum type using KClass.