final classadt extends Annotation with StaticAnnotation
An annotation that designates that a sealed trait is an algebraic datatype
(ADT), and that a field containing the serialized childrens' types should be
added to the final JSON objects.
Note that by default all sealed traits are treated as ADTs, with a type
field called type. This annotation enables overriding the name of that
field and is really only useful if a child itself has a field called type
that would otherwise result in a conflict.
Example:
// the JSON field "kind" will contain the actual type of the serialized child
@adt("kind") sealedabstractclass Keyword(`type`: String)
caseclass If(`type`: String) extends Keyword(`type`)
Linear Supertypes
StaticAnnotation, Annotation, AnyRef, Any
Ordering
Alphabetic
By Inheritance
Inherited
adt
StaticAnnotation
Annotation
AnyRef
Any
Hide All
Show All
Visibility
Public
All
Instance Constructors
newadt(typeFieldName: String = "type")
typeFieldName
the name of the field to inject into a serialized JSON
object
An annotation that designates that a sealed trait is an algebraic datatype (ADT), and that a field containing the serialized childrens' types should be added to the final JSON objects.
Note that by default all sealed traits are treated as ADTs, with a type field called
type
. This annotation enables overriding the name of that field and is really only useful if a child itself has a field calledtype
that would otherwise result in a conflict.Example: