DiscriminatorKind

zio.blocks.schema.toon.DiscriminatorKind
See theDiscriminatorKind companion object
sealed trait DiscriminatorKind

Represents the strategy for specifying the discriminator used in a TOON schema for distinguishing between different subtypes of a sealed hierarchy.

Implementations of this trait define how the discriminator is represented in the serialized TOON, if any.

The possible discriminator kinds include:

  • Field with adding a custom field named as specified in the name parameter that contains a value of the subtype discriminator, e.g. type: Person followed by the record fields for case class Person(...) extends SealedTrait
  • Key, where the discriminator is represented as a TOON key with wrapping of the encoded value in a nested record, e.g. Person: followed by indented fields for case class Person(...) extends SealedTrait.
  • None, where no discriminator is used, meaning subtype differentiation is handled by sequential attempts to parse all possible subtypes, starting from the first subtype, until a successful parse is found, or an error is thrown if none of the subtypes can be parsed from the input.

Attributes

Companion
object
Source
DiscriminatorKind.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class Field
object Key
object None
In this article