Skip to content

Commit bf3aeab

Browse files
committed
Fix ValueEnum names and Scaladocs (#31)
A bunch of stuff was copy pasted from EnumEntry and still referred to things like names
1 parent 2eaabc1 commit bf3aeab

File tree

1 file changed

+7
-7
lines changed
  • enumeratum-core/compat/src/main/scala-2.11/enumeratum/values

1 file changed

+7
-7
lines changed

enumeratum-core/compat/src/main/scala-2.11/enumeratum/values/ValueEnum.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ import scala.language.experimental.macros
77
sealed trait ValueEnum[ValueType <: AnyVal, EntryType <: ValueEnumEntry[ValueType]] {
88

99
/**
10-
* Map of [[EntryType]] object names to [[EntryType]]s
10+
* Map of [[ValueType]] to [[EntryType]] members
1111
*/
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
1313

1414
/**
1515
* 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`
1717
* and friends are as efficient as possible.
1818
*
1919
* 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
2222
def values: Seq[EntryType]
2323

2424
/**
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
2626
* of the case objects implementing [[EntryType]]
2727
*
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.
3030
*/
3131
def withValue(i: ValueType): EntryType = withValueOpt(i).getOrElse(throw new NoSuchElementException(buildNotFoundMessage(i)))
3232

3333
/**
3434
* Optionally returns an [[EntryType]] for a given value.
3535
*/
36-
def withValueOpt(i: ValueType): Option[EntryType] = intToValuesMap.get(i)
36+
def withValueOpt(i: ValueType): Option[EntryType] = valuesToEntriesMap.get(i)
3737

3838
private lazy val existingEntriesString = values.map(_.value).mkString(", ")
3939

0 commit comments

Comments
 (0)