julienrf.enum
sealed trait Foo object Foo { case object Bar extends Foo case object Baz extends Foo val enum: Enum[Foo] = Enum[Foo] } assert(Foo.enum.values == Set(Foo.Bar, Foo.Baz)) assert(Foo.enum.labels == Set("Bar", "Baz")) assert(Foo.enum.encode(Foo.Bar) == "Bar") assert(Foo.enum.decode("Baz") == Right(Foo.Baz)) assert(Foo.enum.decode("invalid") == Left(DecodingFailure[Foo](Set("Bar", "Baz"))))
Type of the enumeration values
The value corresponding to the given label
label
The label of the given value a
a
All the labels of the enumeration
All the values of the enumeration
Convenient shorthand for decode that returns an Option[A]
decode
Option[A]
Type of the enumeration values