trait IntPlayEnum[EnumEntry <: IntEnumEntry] extends IntEnum[EnumEntry] with IntPlayPathBindableValueEnum[EnumEntry] with IntPlayQueryBindableValueEnum[EnumEntry] with IntPlayFormValueEnum[EnumEntry] with IntPlayJsonValueEnum[EnumEntry]
An IntEnum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
Things included are:
- implicit PathBindable (for binding from request path)
- implicit QueryStringBindable (for binding from query strings)
- formField for doing things like
Form("hello" -> MyEnum.formField) - implicit Json format
Example:
scala> import enumeratum.values._ scala> import play.api.data.Form scala> import play.api.libs.json._ scala> sealed abstract class Greeting(val value:Int) extends IntEnumEntry scala> object Greeting extends IntPlayEnum[Greeting] { | val values = findValues | case object Hello extends Greeting(1) | case object GoodBye extends Greeting(2) | case object Hi extends Greeting(3) | case object Bye extends Greeting(4) | } scala> val form = Form("greeting" -> Greeting.formField) scala> form.bind(Map("greeting" -> "1")).value res0: Option[Greeting] = Some(Hello)
scala> Json.toJson(Greeting.Hello) res1: JsValue = 1
Linear Supertypes
Ordering
- Alphabetic
- By Inheritance
Inherited
- IntPlayEnum
- IntPlayJsonValueEnum
- PlayJsonValueEnum
- IntPlayFormValueEnum
- PlayFormValueEnum
- IntPlayQueryBindableValueEnum
- PlayQueryBindableValueEnum
- IntPlayPathBindableValueEnum
- PlayPathBindableValueEnum
- IntEnum
- IntEnumCompat
- ValueEnum
- AnyRef
- Any
- Hide All
- Show All
Visibility
- Public
- All
Abstract Value Members
-
abstract
def
values: IndexedSeq[EnumEntry]
- Definition Classes
- ValueEnum
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
val
baseFormatter: Formatter[Int]
The Formatter for binding the ValueType of this ValueEnum.
The Formatter for binding the ValueType of this ValueEnum.
Used for building the Formatter for the entries
- Attributes
- protected
- Definition Classes
- IntPlayFormValueEnum → PlayFormValueEnum
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native() @HotSpotIntrinsicCandidate()
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
macro
def
findValues: IndexedSeq[EnumEntry]
- Attributes
- protected
- Definition Classes
- IntEnumCompat
-
lazy val
formField: Mapping[EnumEntry]
Field for mapping this enum in Forms
Field for mapping this enum in Forms
- Definition Classes
- PlayFormValueEnum
-
implicit
val
format: Format[EnumEntry]
- Definition Classes
- IntPlayJsonValueEnum → PlayJsonValueEnum
-
lazy val
fromPath: PathBindableExtractor[EnumEntry]
Binder for play.api.routing.sird router
Binder for play.api.routing.sird router
Example:
scala> import play.api.routing.sird._ scala> import play.api.routing._ scala> import play.api.mvc._ scala> sealed abstract class Greeting(val value: Int) extends IntEnumEntry scala> object Greeting extends IntPlayEnum[Greeting] { | val values = findValues | case object Hello extends Greeting(1) | case object GoodBye extends Greeting(2) | case object Hi extends Greeting(3) | case object Bye extends Greeting(4) | } scala> val router = Router.from { | case GET(p"/hello/${Greeting.fromPath(greeting)}") => Action { | Results.Ok(s"$greeting") | } | } scala> router.routes res0: Router.Routes = <function1>
- Definition Classes
- PlayPathBindableValueEnum
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
implicit
val
pathBindable: PathBindable[EnumEntry]
Implicit path binder for Play's default router
Implicit path binder for Play's default router
- Definition Classes
- IntPlayPathBindableValueEnum → PlayPathBindableValueEnum
-
implicit
val
queryBindable: QueryStringBindable[EnumEntry]
Implicit path binder for Play's default router
Implicit path binder for Play's default router
- Definition Classes
- IntPlayQueryBindableValueEnum → PlayQueryBindableValueEnum
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
lazy val
valuesToEntriesMap: Map[Int, EnumEntry]
- Definition Classes
- ValueEnum
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
def
withValue(i: Int): EnumEntry
- Definition Classes
- ValueEnum
- Annotations
- @SuppressWarnings()
-
def
withValueEither(i: Int): Either[NoSuchMember[Int, ValueEnumEntry[Int]], EnumEntry]
- Definition Classes
- ValueEnum
-
def
withValueOpt(i: Int): Option[EnumEntry]
- Definition Classes
- ValueEnum
Deprecated Value Members
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] ) @Deprecated
- Deprecated