enumeratum
package enumeratum
- Alphabetic
- Public
- All
Type Members
-
trait
PlayEnum
[A <: EnumEntry] extends Enum[A] with PlayJsonEnum[A] with PlayPathBindableEnum[A] with PlayQueryBindableEnum[A] with PlayFormFieldEnum[A]
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
Note, the binders created here are case-sensitive.
Things included are:
- implicit JSON format
- implicit PathBindable (for binding from request path)
- implicit QueryStringBindable (for binding from query strings)
- formField for doing things like
Form("hello" -> MyEnum.formField)
Example:
scala> import enumeratum._ scala> import play.api.data.Form scala> import play.api.libs.json._ scala> sealed trait Greeting extends EnumEntry scala> object Greeting extends PlayEnum[Greeting] { | val values = findValues | case object Hello extends Greeting | case object GoodBye extends Greeting | case object Hi extends Greeting | case object Bye extends Greeting | } scala> val form = Form("greeting" -> Greeting.formField) scala> form.bind(Map("greeting" -> "Hello")).value res0: Option[Greeting] = Some(Hello)
scala> Json.toJson(Greeting.Hello) res1: JsValue = "Hello"
- trait PlayFormFieldEnum [A <: EnumEntry] extends AnyRef
-
trait
PlayLowercaseEnum
[A <: EnumEntry] extends Enum[A] with PlayLowercaseJsonEnum[A] with PlayLowercasePathBindableEnum[A] with PlayLowercaseQueryBindableEnum[A] with PlayLowercaseFormFieldEnum[A]
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
Note, the binders created here transform to lower case.
Things included are:
- implicit JSON format
- implicit PathBindable (for binding from request path)
- implicit QueryStringBindable (for binding from query strings)
- formField for doing things like
Form("hello" -> MyEnum.formField)
- trait PlayLowercaseFormFieldEnum [A <: EnumEntry] extends AnyRef
- trait PlayLowercasePathBindableEnum [A <: EnumEntry] extends AnyRef
- trait PlayLowercaseQueryBindableEnum [A <: EnumEntry] extends AnyRef
- trait PlayPathBindableEnum [A <: EnumEntry] extends AnyRef
- trait PlayQueryBindableEnum [A <: EnumEntry] extends AnyRef
-
trait
PlayUppercaseEnum
[A <: EnumEntry] extends Enum[A] with PlayUppercaseJsonEnum[A] with PlayUppercasePathBindableEnum[A] with PlayUppercaseQueryBindableEnum[A] with PlayUppercaseFormFieldEnum[A]
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
An Enum that has a lot of the Play-related implicits built-in so you can avoid boilerplate.
Note, the binders created here transform to upper case.
Things included are:
- implicit JSON format
- implicit PathBindable (for binding from request path)
- implicit QueryStringBindable (for binding from query strings)
- formField for doing things like
Form("hello" -> MyEnum.formField)
- trait PlayUppercaseFormFieldEnum [A <: EnumEntry] extends AnyRef
- trait PlayUppercasePathBindableEnum [A <: EnumEntry] extends AnyRef
- trait PlayUppercaseQueryBindableEnum [A <: EnumEntry] extends AnyRef
Value Members
-
object
Forms
Created by Lloyd on 2/3/15.
-
object
UrlBinders
Created by Lloyd on 2/3/15.