EnumishEntriesHolder

abstract class EnumishEntriesHolder<T : Enumish>

Base class of the per-hierarchy EntriesHolder the plugin generates: holds the entries list, its lazy initialization and the label lookup. User code normally goes through the generated Enumish companion (EnumishCompanion) instead of this type.

Takes no constructor parameters so the generated subclass needs only a no-arg super call; the hierarchy is identified by enumizedRootClass.

Do not read entries or the lookup functions from initializers of kinds (leaf objects or companions): that re-enters the lazy initialization and the behavior is undefined — double initialization, deadlock or a runtime failure depending on the platform. This is the same rule as not touching values() from an enum constructor.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
val entries: List<T>

All kinds of the hierarchy; built once on first access, then reused.

Functions

Link copied to clipboard
fun getByLabel(label: String): T

Returns the kind whose label equals label. The failure message identifies the hierarchy by the root's simple name, because qualified names are unavailable on some platforms (e.g. JS).

Link copied to clipboard
fun getByLabelOrNull(label: String): T?

Returns the first kind whose label equals label, or null. Labels are unique per hierarchy (enforced at compile time), so the match is unambiguous.