Package

macrame.play

enums

Permalink

package enums

Visibility
  1. Public
  2. All

Type Members

  1. trait AsJson[Enum] extends AnyRef

    Permalink

    This trait provides an instance of Writes for an enumeration.

    This trait provides an instance of Writes for an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends AsJson[Color]
  2. trait FromJson[Enum] extends AnyRef

    Permalink

    This trait provides an instance of Reads for an enumeration.

    This trait provides an instance of Reads for an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromJson[Color]

    If you need your Reads instance to be case-insensitive you can override the caseSensitive member like so:

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromJson[Color] {
      override val caseSensitive = false
    }
  3. trait FromJsonNumeric[Enum] extends AnyRef

    Permalink

    This trait provides an instance of Reads for an enumeration.

    This trait provides an instance of Reads for an enumeration. Unlike FromJson, the Reads instance created by this trait operates on JsNumber using the Int representation of the enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends FromJsonNumeric[Color]

    Allows you to read JSON numbers as Color like so:

    JsNumber(0).validate[Color] // JsResult(Red)
  4. trait JsonConverters[Enum] extends AsJson[Enum] with FromJson[Enum]

    Permalink

    This trait provides an instance of Format for an enumeration.

    This trait provides an instance of Format for an enumeration. It works by extending the companion object of the enumeration class.

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends JsonConverters[Color]

    If you need your Format instance to be case-insensitive you can override the caseSensitive member like so:

    @enum class Color {
      Red
      Blue
      Yellow
    }
    object Color extends JsonConverters[Color] {
      override val caseSensitive = false
    }

Ungrouped