Name of the final val in enum companion object that this enum value is assigned to.
Enum value index, starting from 0.
Enum value index, starting from 0. Reflects the order in which enum constants are declared in the companion object of the enum class.
Base trait for
val-based enums, i.e. enums implemented as a single class with companion object keeping enum values as instances of the enum class infinal valfields. This is an alternative way of implementing enums as compared to traditional Scala approach of using a sealed hierarchy with objects representing enum values.Advantages of value based enums over object based enums include:
valuesin enum's companion object as it is necessary when using SealedEnumCompanion and NamedEnumCompanionDisadvantages of value based enums over object based enums include:
commons-analyzercompiler plugin.Enum classes must have a companion object which extends ValueEnumCompanion (prefer using AbstractValueEnumCompanion where possible). Every enum constant must be declared as a
final valin the companion object and must have theValuetype explicitly ascribed. The enum class itself must take an implicit EnumCtx argument which provides information about enum ordinal and name as well as makes sure that enum value is registered in the companion object. If possible, you should always extend AbstractValueEnum instead of mixing in this trait. ValueEnum trait should only be mixed in directly when your enum class already has another superclass, incompatible with AbstractValueEnum.Value based enums can take parameters: