package scalaenum
Type Members
-
abstract
class
Enum extends Serializable
Defines a finite set of values specific to the enumeration.
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 asval
members of the evaluation.All values in an enumeration share a common, unique type defined as the abstract
Value
type member of the enumeration (Value
selected on the stable identifier path of the enumeration instance). Besides, in contrast to Scala's built-in Enumeration, theValue
type member can be extended in subclasses, such that it is possible to mix-in traits, for example. In this case, make sure to make the constructor ofValue
private. Example:// adding methods to Value class Day private extends Day.Val { def isWorkingDay: Boolean = this != Day.Saturday && this != Day.Sunday } object Day extends Enum { type Value = Day val Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday = new Day } // usage: Day.values filter (_.isWorkingDay) foreach println // output: // Monday // Tuesday // Wednesday // Thursday // Friday
- Annotations
- @SerialVersionUID()