Trait/Object

fm.common

Enum

Related Docs: object Enum | package common

Permalink

trait Enum[A <: EnumEntry] 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.

Example:

scala> sealed trait DummyEnum extends EnumEntry
defined trait DummyEnum

scala> object DummyEnum extends Enum[DummyEnum] {
     |   val values = findValues
     |   case object Hello   extends DummyEnum
     |   case object GoodBye extends DummyEnum
     |   case object Hi      extends DummyEnum
     | }

scala> DummyEnum.withNameOption("Hello")
res0: Option[DummyEnum] = Some(Hello)

scala> DummyEnum.withNameOption("Nope")
res1: Option[DummyEnum] = None
A

The sealed trait

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Enum
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def values: IndexedSeq[A]

    Permalink

    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 messing around with ordering, etc) if that fits your needs better.

Concrete 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. final def asInstanceOf[T0]: T0

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

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

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

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

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

    Permalink

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

    Method that returns a Seq 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[_]

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

    Permalink
    Definition Classes
    AnyRef → Any
  12. def indexOf(member: A): Int

    Permalink

    Returns the index number of the member passed in the values picked up by this enum

    Returns the index number of the member passed in the values picked up by this enum

    member

    the member you want to check the index of

    returns

    the index of the first element of values that is equal (as determined by ==) to member, or -1, if none exists.

  13. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  14. final lazy val lowerCaseNamesToValuesMap: Map[String, A]

    Permalink

    Map of A object names in lower case to As for case-insensitive comparison

  15. lazy val namesToValuesMap: Map[String, A]

    Permalink

    Map of A object names to As

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

    Permalink
    Definition Classes
    AnyRef
  17. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  18. final def notifyAll(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef → Any
  21. final lazy val upperCaseNameValuesToMap: Map[String, A]

    Permalink

    Map of A object names in upper case to As for case-insensitive comparison

  22. final lazy val valuesToIndex: Map[A, Int]

    Permalink

    Map of A to their index in the values sequence.

    Map of A to their index in the values sequence.

    A performance optimisation so that indexOf can be found in constant time.

  23. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  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. def withName(name: String): A

    Permalink

    Tries to get an A by the supplied name.

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

    Like withName, this method will throw if the name does not match any of the values' .entryName values.

  27. def withNameInsensitive(name: String): A

    Permalink

    Tries to get an A by the supplied name.

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

    Like withName, this method will throw if the name does not match any of the values' .entryName values.

  28. def withNameInsensitiveOption(name: String): Option[A]

    Permalink

    Optionally returns an A for a given name, disregarding case

  29. def withNameLowercaseOnly(name: String): A

    Permalink

    Tries to get an A by the supplied name.

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

    Like withName, this method will throw if the name does not match any of the values' .entryName values.

  30. def withNameLowercaseOnlyOption(name: String): Option[A]

    Permalink

    Optionally returns an A for a given name assuming the value is lower case

  31. def withNameOption(name: String): Option[A]

    Permalink

    Optionally returns an A for a given name.

  32. def withNameUppercaseOnly(name: String): A

    Permalink

    Tries to get an A by the supplied name.

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

    Like withName, this method will throw if the name does not match any of the values' .entryName values.

  33. def withNameUppercaseOnlyOption(name: String): Option[A]

    Permalink

    Optionally returns an A for a given name assuming the value is upper case

Inherited from AnyRef

Inherited from Any

Ungrouped