Class

io.github.memo33.scalaenum

Enum

Related Doc: package scalaenum

Permalink

abstract class Enum 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 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, the Value 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 of Value 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
Self Type
Enum
Annotations
@SerialVersionUID()
Linear Supertypes
Serializable, Serializable, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Enum
  2. Serializable
  3. Serializable
  4. AnyRef
  5. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Enum()

    Permalink
  2. new Enum(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 Ordered[Value] with Serializable

    Permalink

    The superclass of the scala.Enum.Value type.

    The superclass of the scala.Enum.Value type. This class can be overridden to change the enumeration's naming and integer identification behaviour, as well as to add additional public functionality.

    Annotations
    @SerialVersionUID()
  2. abstract type Value <: Val

    Permalink

    The type of the enumerated values.

  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. implicit object ValueOrdering extends Ordering[Value]

    Permalink

    An ordering by id for values of this set

  5. object ValueSet extends Serializable

    Permalink

    A factory object for value sets

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

    Permalink

    The value of this enumeration with given id x

  7. final def asInstanceOf[T0]: T0

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

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  11. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate()
  12. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final def maxId: Int

    Permalink

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

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

    Permalink
    Definition Classes
    AnyRef
  16. 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
  17. 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
  18. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate()
  19. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate()
  20. def readResolve(): AnyRef

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

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

    Permalink

    The name of this enumeration.

    The name of this enumeration.

    Definition Classes
    Enum → AnyRef → Any
  23. def values: ValueSet

    Permalink

    The values of this enumeration as a set.

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(): Unit

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

    Permalink

    Return a Value from this Enum whose name matches the argument s.

    Return a Value from this Enum whose name matches the argument s. The names are determined automatically via reflection.

    s

    an Enum name

    returns

    the Value of this Enum if its name matches s

    Exceptions thrown

    NoSuchElementException if no Value with a matching name is in this Enum

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from Serializable

Inherited from Serializable

Inherited from AnyRef

Inherited from Any

Ungrouped