trait SealedEnumCompanion[T] extends AnyRef
Base trait for companion objects of sealed traits that serve as enums, i.e. their only values are case objects. For example:
sealed trait SomeEnum object SomeEnum extends SealedEnumCompanion[SomeEnum] { case object FirstValue extends SomeEnum case object SecondValue extends SomeEnum case object ThirdValue extends SomeEnum // it's important to explicitly specify the type so that `caseObjects` macro works properly val values: List[SomeEnum] = caseObjects }
Linear Supertypes
Known Subclasses
Ordering
- Alphabetic
- By Inheritance
Inherited
- SealedEnumCompanion
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Abstract Value Members
-
abstract
val
values: commons.ISeq[T]
Holds a list of all case objects of a sealed trait or class
T
.Holds a list of all case objects of a sealed trait or class
T
. This must be implemented separately for every sealed enum, but can be implemented simply by using the caseObjects macro. It's important to *always* state the type ofvalues
explicitly, as a workaround for SI-7046. For example:val values: List[MyEnum] = caseObjects
Also, be aware that caseObjects macro guarantees well-defined order of elements only for OrderedEnum.
Concrete Value Members
-
implicit
def
evidence: SealedEnumCompanion.this.type
Thanks to this implicit, SealedEnumCompanion and its subtraits can be used as typeclasses.