enumeratum

Enum

trait Enum[A] extends AnyRef

All the cool kids have their own Enumeration implementation, most of which try to do so in the name of implementing exhaustive pattern matching.

This is yet another one.

Oh yeah, Enum is BYOO (bring your own ordinality). Take care of that when you implement the value method.

How to use:

sealed trait DummyEnum

object DummyEnum extends Enum[DummyEnum] {

val values = findValues.toIndexedSeq

case object Hello extends DummyEnum
case object GoodBye extends DummyEnum
case object Hi extends DummyEnum

}


DummyEnum.values should be(Set(Hello, GoodBye, Hi))

DummyEnum.withName("Hello") should be(Hello)
A

The sealed trait you want to use as the main

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Enum
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def values: Iterable[A]

    The sequence of values for your Enum.

    The sequence of values for your Enum. You will typically want to implement this in your extending class as a val so that withName and friends are as efficient as possible.

    Feel free to implement this however you'd like (including ordering, etc) if that fits your needs better.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  5. def clone(): AnyRef

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

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

    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  9. macro def findValues: Set[A]

    Method that returns the Set of A objects that the macro was able to find.

    Method that returns the Set of A objects that the macro was able to find.

    You will want to use this in some way to implement your values method. In fact, if you aren't using this method...why are you even bothering with this lib?

    Attributes
    protected
  10. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  13. final lazy val namesToValuesMap: Map[String, A]

    Map of A object names to As

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

    Definition Classes
    AnyRef
  15. final def notify(): Unit

    Definition Classes
    AnyRef
  16. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  18. def toString(): String

    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  22. def withName(name: String): A

    Tries to get an A by the supplied name.

    Tries to get an A by the supplied name. The name corresponds to the .toString of the case objects implementing A

Inherited from AnyRef

Inherited from Any

Ungrouped