enumeratum

package enumeratum

Members list

Concise view

Type members

Classlikes

trait ArgonautEnum[A <: EnumEntry]

Trait that automatically adds Argonaut Json Encoders and Decoders typeclasses to your Enumeratum enums.

Trait that automatically adds Argonaut Json Encoders and Decoders typeclasses to your Enumeratum enums.

Example:

scala> import enumeratum._
scala> import argonaut._
scala> import Argonaut._

scala> sealed trait TrafficLight extends EnumEntry
scala> case object TrafficLight extends Enum[TrafficLight] with ArgonautEnum[TrafficLight] {
     |   case object Red    extends TrafficLight
     |   case object Yellow extends TrafficLight
     |   case object Green  extends TrafficLight
     |   val values = findValues
     | }

scala> val light: TrafficLight = TrafficLight.Red
scala> light.asJson
res0: Json = "Red"

scala> Json.jString("Red").as[TrafficLight]
res1: DecodeResult[TrafficLight] = DecodeResult(Right(Red))

scala> Json.jString("Purple").as[TrafficLight]
res1: DecodeResult[TrafficLight] = DecodeResult(Left(('Purple' is not a member of enum TrafficLight,CursorHistory(List()))))

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Enum[A]
object Argonauter

Created by alonsodomin on 14/10/2016.

Created by alonsodomin on 14/10/2016.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type