Package

enumeratum

Permalink

package enumeratum

Visibility
  1. Public
  2. All

Type Members

  1. trait PlayEnum[A <: EnumEntry] extends Enum[A] with PlayJsonEnum[A] with PlayPathBindableEnum[A] with PlayQueryBindableEnum[A] with PlayFormFieldEnum[A]

    Permalink

    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"

  2. trait PlayFormFieldEnum[A <: EnumEntry] extends AnyRef

    Permalink
  3. trait PlayLowercaseEnum[A <: EnumEntry] extends Enum[A] with PlayLowercaseJsonEnum[A] with PlayLowercasePathBindableEnum[A] with PlayLowercaseQueryBindableEnum[A] with PlayLowercaseFormFieldEnum[A]

    Permalink

    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)
  4. trait PlayLowercaseFormFieldEnum[A <: EnumEntry] extends AnyRef

    Permalink
  5. trait PlayLowercasePathBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink
  6. trait PlayLowercaseQueryBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink
  7. trait PlayPathBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink
  8. trait PlayQueryBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink
  9. trait PlayUppercaseEnum[A <: EnumEntry] extends Enum[A] with PlayUppercaseJsonEnum[A] with PlayUppercasePathBindableEnum[A] with PlayUppercaseQueryBindableEnum[A] with PlayUppercaseFormFieldEnum[A]

    Permalink

    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)
  10. trait PlayUppercaseFormFieldEnum[A <: EnumEntry] extends AnyRef

    Permalink
  11. trait PlayUppercasePathBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink
  12. trait PlayUppercaseQueryBindableEnum[A <: EnumEntry] extends AnyRef

    Permalink

Value Members

  1. object Forms

    Permalink

    Created by Lloyd on 2/3/15.

  2. object UrlBinders

    Permalink

    Created by Lloyd on 2/3/15.

  3. package values

    Permalink

Ungrouped