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
Valuemethod adds a new unique value to the enumeration. To be accessible, these values are usually defined asvalmembers of the evaluation.All values in an enumeration share a common, unique type defined as the abstract
Valuetype member of the enumeration (Valueselected on the stable identifier path of the enumeration instance). Besides, in contrast to Scala's built-in Enumeration, theValuetype 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 ofValueprivate. 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()