@@ -7,13 +7,13 @@ import scala.language.experimental.macros
7
7
sealed trait ValueEnum [ValueType <: AnyVal , EntryType <: ValueEnumEntry [ValueType ]] {
8
8
9
9
/**
10
- * Map of [[EntryType ]] object names to [[EntryType ]]s
10
+ * Map of [[ValueType ]] to [[EntryType ]] members
11
11
*/
12
- lazy final val intToValuesMap : Map [ValueType , EntryType ] = values.map(v => v.value -> v).toMap
12
+ final lazy val valuesToEntriesMap : Map [ValueType , EntryType ] = values.map(v => v.value -> v).toMap
13
13
14
14
/**
15
15
* The sequence of values for your [[Enum ]]. You will typically want
16
- * to implement this in your extending class as a `val` so that `withName `
16
+ * to implement this in your extending class as a `val` so that `withValue `
17
17
* and friends are as efficient as possible.
18
18
*
19
19
* Feel free to implement this however you'd like (including messing around with ordering, etc) if that
@@ -22,18 +22,18 @@ sealed trait ValueEnum[ValueType <: AnyVal, EntryType <: ValueEnumEntry[ValueTyp
22
22
def values : Seq [EntryType ]
23
23
24
24
/**
25
- * Tries to get an [[EntryType ]] by the supplied value. The name corresponds to the .value
25
+ * Tries to get an [[EntryType ]] by the supplied value. The value corresponds to the .value
26
26
* of the case objects implementing [[EntryType ]]
27
27
*
28
- * Like [[Enumeration ]]'s `withName `, this method will throw if the name does not match any of the values'
29
- * .entryName values.
28
+ * Like [[Enumeration ]]'s `withValue `, this method will throw if the value does not match any of the values'
29
+ * `.value` values.
30
30
*/
31
31
def withValue (i : ValueType ): EntryType = withValueOpt(i).getOrElse(throw new NoSuchElementException (buildNotFoundMessage(i)))
32
32
33
33
/**
34
34
* Optionally returns an [[EntryType ]] for a given value.
35
35
*/
36
- def withValueOpt (i : ValueType ): Option [EntryType ] = intToValuesMap .get(i)
36
+ def withValueOpt (i : ValueType ): Option [EntryType ] = valuesToEntriesMap .get(i)
37
37
38
38
private lazy val existingEntriesString = values.map(_.value).mkString(" , " )
39
39
0 commit comments