Discriminated

alloy.Discriminated
object Discriminated extends Newtype[String]

Discriminated unions contain the information about which branch of a union is encoded inside of the object itself. The following union: structure One { a: Int } structure Two { b: String } union Test { one: One two: Two } would normally be encoded in JSON as: { "one": { "a": 123 } } when annotated with ``@discriminated("type"), it will instead be encoded as: { "a": 123, "type": "one" } This is more efficient than using an untagged encoding, but less efficient than using the default tagged union encoding. Therefore, it should only be used when necessary. Tagged union encodings should be used wherever possible.

Attributes

Graph
Supertypes
class Newtype[String]
trait HasId
class Object
trait Matchable
class Any
Self type

Members list

Type members

Inherited classlikes

object hint

Attributes

Inherited from:
Newtype
Supertypes
class Object
trait Matchable
class Any

Inherited types

opaque type Type

Attributes

Inherited from:
Newtype

Value members

Inherited methods

def apply(a: String): Type

Attributes

Inherited from:
Newtype
def unapply(orig: Type): Some[A]

Attributes

Inherited from:
Newtype

Concrete fields

val hints: Hints
val id: ShapeId

Extensions

Inherited extensions

extension (orig: Type)
def value: A

Attributes

Inherited from:
Newtype

Implicits

Implicits

implicit val schema: Schema[Discriminated]

Inherited implicits

implicit val asBijection: Bijection[String, Type]

Attributes

Inherited from:
Newtype
implicit val tag: ShapeTag[Type]

Attributes

Inherited from:
Newtype