scala

Enumeration

class Enumeration extends AnyRef

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).

Example use

 object Main extends Application {

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.iterator filter isWorkingDay foreach println }

attributes: abstract
go to: companion
known subclasses: RoundingMode, Key, Location, ElementMode, IntervalMode, AutoResizeMode, Layout, State, BarPolicy, Result, Options, Message, Orientation, IntervalMode, Anchor, Fill, FocusLostBehavior, Alignment, SelectionMode, Result, Position, Alignment
source: Enumeration.scala
    version
  1. 1.0, 10/02/2004

    authors:
  1. Matthias Zenger

Inherited
  1. Hide All
  2. Show all
  1. AnyRef
  2. Any
Visibility
  1. Public
  2. All

Instance constructors

  1. new Enumeration(names: String*)

  2. new Enumeration()

  3. new Enumeration(initial: Int, names: String*)

Type Members

  1. class Val extends Value

    A class implementing the Value type.

  2. class Value extends Ordered[Value]

    The type of the enumerated values.

  3. class ValueSet extends Set[Value] with SetLike[Value, ValueSet]

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

Value Members

  1. def !=(arg0: AnyRef): Boolean

  2. def !=(arg0: Any): Boolean

    o != arg0 is the same as !(o == (arg0)).

  3. def ##(): Int

  4. def $asInstanceOf[T0](): T0

  5. def $isInstanceOf[T0](): Boolean

  6. def ==(arg0: AnyRef): Boolean

    o == arg0 is the same as if (o eq null) arg0 eq null else o.equals(arg0).

  7. def ==(arg0: Any): Boolean

    o == arg0 is the same as o.equals(arg0).

  8. def Value(i: Int, name: String): Value

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

  9. def Value(name: String): Value

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

  10. def Value(i: Int): Value

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

  11. def Value: Value

    Creates a fresh value, part of this enumeration.

  12. object ValueSet extends AnyRef

    A factory object for value sets

  13. def apply(x: Int): Value

    The value of this enumeration with given id x

  14. def asInstanceOf[T0]: T0

    This method is used to cast the receiver object to be of type T0.

  15. def clone(): AnyRef

    This method creates and returns a copy of the receiver object.

  16. def eq(arg0: AnyRef): Boolean

    This method is used to test whether the argument (arg0) is a reference to the receiver object (this).

  17. def equals(arg0: Any): Boolean

    This method is used to compare the receiver object (this) with the argument object (arg0) for equivalence.

  18. def exists(p: (Value) ⇒ Boolean): Boolean

    Apply a predicate p to all values of this enumeration and return true, iff there is at least one value for which p yields true.

  19. def filter(p: (Value) ⇒ Boolean): Iterator[Value]

    Returns all values of this enumeration that satisfy the predicate p.

  20. def finalize(): Unit

    This method is called by the garbage collector on the receiver object when garbage collection determines that there are no more references to the object.

  21. def flatMap[B](f: (Value) ⇒ Iterator[B]): Iterator[B]

    Applies the given function f to each value of this enumeration, then concatenates the results.

  22. def forall(p: (Value) ⇒ Boolean): Boolean

    Apply a predicate p to all values of this enumeration and return true, iff the predicate yields true for all values.

  23. def foreach(f: (Value) ⇒ Unit): Unit

    Apply a function f to all values of this enumeration.

  24. def getClass(): java.lang.Class[_ <: java.lang.Object]

    Returns a representation that corresponds to the dynamic class of the receiver object.

  25. def hashCode(): Int

    Returns a hash code value for the object.

  26. def isInstanceOf[T0]: Boolean

    This method is used to test whether the dynamic type of the receiver object is T0.

  27. def iterator: Iterator[Value]

    A new iterator over all values of this enumeration.

  28. def map[B](f: (Value) ⇒ B): Iterator[B]

    Returns an iterator resulting from applying the given function f to each value of this enumeration.

  29. def maxId: Int

    The highest integer amongst those used to identify values in this enumeration.

  30. def name: String

    The name of this enumeration.

  31. def ne(arg0: AnyRef): Boolean

    o.ne(arg0) is the same as !(o.eq(arg0)).

  32. var nextId: Int

    The integer to use to identify the next created value.

  33. var nextName: Iterator[String]

    The string to use to name the next created value.

  34. def notify(): Unit

    Wakes up a single thread that is waiting on the receiver object's monitor.

  35. def notifyAll(): Unit

    Wakes up all threads that are waiting on the receiver object's monitor.

  36. def readResolve(): AnyRef

  37. def synchronized[T0](arg0: T0): T0

  38. def toString(): String

    The name of this enumeration.

  39. def valueOf(s: String): Option[Value]

  40. def values: ValueSet

    The values of this enumeration as a set.

  41. def wait(): Unit

  42. def wait(arg0: Long, arg1: Int): Unit

  43. def wait(arg0: Long): Unit

  44. def withName(s: String): Value

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