Packages

c

scala

Enumeration

abstract class Enumeration extends Serializable

Defines a finite set of values specific to the enumeration. Typically these values enumerate all possible forms something can take and provide a lightweight alternative to case classes.

Each call to a Value method adds a new unique value to the enumeration. To be accessible, these values are usually defined as val members of the evaluation.

All values in an enumeration share a common, unique type defined as the Value type member of the enumeration (Value selected on the stable identifier path of the enumeration instance).

Self Type
Enumeration
Annotations
@SerialVersionUID()
Source
Enumeration.scala
Example:
  1. object Main extends App {
    
      object WeekDay extends Enumeration {
        type WeekDay = Value
        val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
      }
      import WeekDay._
    
      def isWorkingDay(d: WeekDay) = ! (d == Sat || d == Sun)
    
      WeekDay.values filter isWorkingDay foreach println
    }
    // output:
    // Mon
    // Tue
    // Wed
    // Thu
    // Fri
Linear Supertypes
Serializable, java.io.Serializable, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Enumeration
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Enumeration()
  2. new Enumeration(initial: Int)

    initial

    The initial value from which to count the integers that identifies values at run-time.

Type Members

  1. abstract class Value extends Ordered[Value] with Serializable

    The type of the enumerated values.

    The type of the enumerated values.

    Annotations
    @SerialVersionUID()
  2. class ValueSet extends AbstractSet[Value] with SortedSet[Value] with SortedSetLike[Value, ValueSet] with Serializable

    A class for sets of values.

    A class for sets of values. Iterating through this set will yield values in increasing order of their ids.

Value Members

  1. final def apply(x: Int): Value

    The value of this enumeration with given id x

  2. final def maxId: Int

    The one higher than the highest integer amongst those used to identify values in this enumeration.

  3. def toString(): String

    The name of this enumeration.

    The name of this enumeration.

    returns

    a String representation of the object.

    Definition Classes
    Enumeration → AnyRef → Any
  4. def values: ValueSet

    The values of this enumeration as a set.

  5. final def withName(s: String): Value

    Return a Value from this Enumeration whose name matches the argument s.

    Return a Value from this Enumeration whose name matches the argument s. The names are determined automatically via reflection.

    s

    an Enumeration name

    returns

    the Value of this Enumeration if its name matches s

    Exceptions thrown

    NoSuchElementException if no Value with a matching name is in this Enumeration

  6. object ValueOrdering extends Ordering[Value]

    An ordering by id for values of this set

  7. object ValueSet extends Serializable

    A factory object for value sets