Class

scala

Enumeration

Related Doc: package scala

Permalink

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()
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
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Enumeration()

    Permalink
  2. new Enumeration(initial: Int)

    Permalink

    initial

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

Type Members

  1. class Val extends Value with Serializable

    Permalink

    A class implementing the scala.Enumeration.Value type.

    A class implementing the scala.Enumeration.Value type. This class can be overridden to change the enumeration's naming and integer identification behaviour.

    Attributes
    protected
    Annotations
    @SerialVersionUID()
  2. abstract class Value extends Ordered[Value] with Serializable

    Permalink

    The type of the enumerated values.

    The type of the enumerated values.

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

    Permalink

    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 !=(arg0: Any): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def Value(i: Int, name: String): Value

    Permalink

    Creates a fresh value, part of this enumeration, called name and identified by the integer i.

    Creates a fresh value, part of this enumeration, called name and identified by the integer i.

    i

    An integer that identifies this value at run-time. It must be unique amongst all values of the enumeration.

    name

    A human-readable name for that value.

    returns

    Fresh value with the provided identifier i and name name.

    Attributes
    protected
  5. final def Value(name: String): Value

    Permalink

    Creates a fresh value, part of this enumeration, called name.

    Creates a fresh value, part of this enumeration, called name.

    name

    A human-readable name for that value.

    returns

    Fresh value called name.

    Attributes
    protected
  6. final def Value(i: Int): Value

    Permalink

    Creates a fresh value, part of this enumeration, identified by the integer i.

    Creates a fresh value, part of this enumeration, identified by the integer i.

    i

    An integer that identifies this value at run-time. It must be unique amongst all values of the enumeration.

    returns

    Fresh value identified by i.

    Attributes
    protected
  7. final def Value: Value

    Permalink

    Creates a fresh value, part of this enumeration.

    Creates a fresh value, part of this enumeration.

    Attributes
    protected
  8. object ValueOrdering extends Ordering[Value]

    Permalink

    An ordering by id for values of this set

  9. object ValueSet extends Serializable

    Permalink

    A factory object for value sets

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

    Permalink

    The value of this enumeration with given id x

  11. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  12. def clone(): AnyRef

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

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

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. final def getClass(): Class[_]

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

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

    Permalink
    Definition Classes
    Any
  19. final def maxId: Int

    Permalink

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

  20. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  21. var nextId: Int

    Permalink

    The integer to use to identify the next created value.

    The integer to use to identify the next created value.

    Attributes
    protected
  22. var nextName: Iterator[String]

    Permalink

    The string to use to name the next created value.

    The string to use to name the next created value.

    Attributes
    protected
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. def readResolve(): AnyRef

    Permalink
    Attributes
    protected
  26. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  27. def toString(): String

    Permalink

    The name of this enumeration.

    The name of this enumeration.

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

    Permalink

    The values of this enumeration as a set.

  29. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  32. final def withName(s: String): Value

    Permalink

    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

Inherited from Serializable

Inherited from java.io.Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped