enumeratum

package enumeratum

Members list

Packages

Type members

Classlikes

object Forms

Created by Lloyd on 2/3/15.

Created by Lloyd on 2/3/15.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
Forms.type
trait PlayEnum[A <: EnumEntry] extends Enum[A], PlayJsonEnum[A], PlayPathBindableEnum[A], PlayQueryBindableEnum[A], 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"

Attributes

Supertypes
trait PlayJsonEnum[A]
trait Enum[A]
class Object
trait Matchable
class Any
Show all
trait PlayFormFieldEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait PlayEnum[A]
Self type
Enum[A]
trait PlayLowercaseEnum[A <: EnumEntry] extends Enum[A], PlayLowercaseJsonEnum[A], PlayLowercasePathBindableEnum[A], PlayLowercaseQueryBindableEnum[A], 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)

Attributes

Supertypes
trait PlayLowercaseJsonEnum[A]
trait Enum[A]
class Object
trait Matchable
class Any
Show all
trait PlayLowercaseFormFieldEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
trait PlayLowercasePathBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
trait PlayLowercaseQueryBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
trait PlayPathBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait PlayEnum[A]
Self type
Enum[A]
trait PlayQueryBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
trait PlayEnum[A]
Self type
Enum[A]
trait PlayUppercaseEnum[A <: EnumEntry] extends Enum[A], PlayUppercaseJsonEnum[A], PlayUppercasePathBindableEnum[A], PlayUppercaseQueryBindableEnum[A], 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)

Attributes

Supertypes
trait PlayUppercaseJsonEnum[A]
trait Enum[A]
class Object
trait Matchable
class Any
Show all
trait PlayUppercaseFormFieldEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
trait PlayUppercasePathBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
trait PlayUppercaseQueryBindableEnum[A <: EnumEntry]

Attributes

Supertypes
class Object
trait Matchable
class Any
Known subtypes
Self type
Enum[A]
object UrlBinders

Created by Lloyd on 2/3/15.

Created by Lloyd on 2/3/15.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
UrlBinders.type