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
- 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[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- macro def findValues: IndexedSeq[EnumEntry]
- Attributes
- protected
- Definition Classes
- IntEnum
- 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[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- 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()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- 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(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- def withValue(i: Int): EnumEntry
- Definition Classes
- ValueEnum
- Annotations
- @SuppressWarnings()
- def withValueOpt(i: Int): Option[EnumEntry]
- Definition Classes
- ValueEnum