On this page
Class scala.Enumeration
@SerialVersionUID(8476000850333817230L)
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 enumeration.
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).
Values SHOULD NOT be added to an enumeration after its construction; doing so makes the enumeration thread-unsafe. If values are added to an enumeration from multiple threads (in a non-synchronized fashion) after construction, the behavior of the enumeration is undefined.
Value parameters |
|
---|---|
Example |
|
Supertypes | |
Known subtypes | |
Self type |
Classlikes
Source@SerialVersionUID(0.-(3501153230598116017L))
A class implementing the scala.Enumeration.Value type. This class can be overridden to change the enumeration's naming and integer identification behaviour.
Source@SerialVersionUID(7091335633555234129L)
The type of the enumerated values.
Source
An ordering by id for values of this set
Source@SerialVersionUID(7229671200427364242L)
class ValueSet extends AbstractSet[Value] with SortedSet[Value] with SortedSetOps[Value, SortedSet, ValueSet] with StrictOptimizedIterableOps[Value, Set, ValueSet] with Serializable
A class for sets of values. Iterating through this set will yield values in increasing order of their ids.
Value parameters |
|
---|---|
Companion | object |
Source@SerialVersionUID(3L)
A factory object for value sets
Companion | class |
---|
Constructors
Source
def this()
Concrete methods
Source
Creates a fresh value, part of this enumeration.
Source
Creates a fresh value, part of this enumeration, identified by the integer i
.
Value parameters |
|
---|---|
Returns | Fresh value identified by |
Source
Creates a fresh value, part of this enumeration, called name
.
Value parameters |
|
---|---|
Returns | Fresh value called |
Source
Creates a fresh value, part of this enumeration, called name
and identified by the integer i
.
Value parameters |
|
---|---|
Returns | Fresh value with the provided identifier |
Source
The value of this enumeration with given id x
Source
The one higher than the highest integer amongst those used to identify values in this enumeration.
Source
protected def readResolve(): AnyRef
Source
The name of this enumeration.
Definition Classes | Any |
---|
Source
The values of this enumeration as a set.
Source
Return a Value
from this Enumeration
whose name matches the argument s
. The names are determined automatically via reflection.
Value parameters |
|
---|---|
Returns | the |
Throws |
|
Concrete fields
Source
The integer to use to identify the next created value.
Source
The string to use to name the next created value.
© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.1.1/scala/Enumeration.html