t

com.avsystem.commons.misc

SealedEnumCompanion

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
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. SealedEnumCompanion
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. 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 of values 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

  1. implicit def evidence: SealedEnumCompanion.this.type

    Thanks to this implicit, SealedEnumCompanion and its subtraits can be used as typeclasses.