org.coursera.common.collection

Enum

Related Doc: package collection

trait Enum[SymbolType <: EnumSymbol] extends AnyRef

Provides a convenient way to define "ADT" based Scala enumerations (enumerations defined with case objects extending a sealed trait) while still retaining the ability to:

- Look up all the symbols of the enumeration - Look up a particular enumeration symbol given its string name

Using case objects for enumerations has some important advantages over using scala.Enumeration:

- Exhaustive pattern matching - The types used to declare enumeration symbols are 1st class scala types

Example usage:

sealed trait Direction extends EnumSymbol

object Direction extends Enum[Direction] { case object NORTH extends Direction case object SOUTH extends Direction case object EAST extends Direction case object WEST extends Direction }

scala> Direction.symbols res1: Set[Direction] = Set(NORTH, SOUTH, EAST, WEST)

scala> Direction.withName("SOUTH") res2: Direction = Direction.SOUTH

Self Type
Enum[SymbolType]
Linear Supertypes
AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Enum
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  6. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  7. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. def findSymbols: Set[SymbolType]

    Attributes
    protected[org.coursera.common.collection]
  10. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  16. lazy val symbols: Set[SymbolType]

    All the symbols of the enumeration.

  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  18. def toString(): String

    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. def withName(name: String): SymbolType

    Gets a Enum symbol by its name.

    Gets a Enum symbol by its name.

    name

    provide the enum symbol's name.

    returns

    the Enum symbol matching the given name.

    Exceptions thrown

    NoSuchElementException if no enum symbol is found for the given name

Inherited from AnyRef

Inherited from Any

Ungrouped