final case class Discriminated[X, D](codec: Codec[D], framing: CodecTransformation) extends Product with Serializable
Wrapper class that indicates subtypes of X
are discriminated by type D
using the supplied Codec[D]
.
For example, an implicit Discriminated
value can be defined in the companion
of a sealed trait, along with implicit Discriminator
values in each subtype
companion. Given such implicits, a codec for the trait can be automatically
derived using Codec[X]
.
Contains an optional codec transformation, which is applied to every component codec before encoding/decoding. This allows common structure, e.g., size based framing, to be specified in one location.
For example, if each discriminated subtype is prefixed by a size field, the framing could be specified as:
Discriminated[X, D](uint, new CodecTransformation { def apply[Z](c: Codec[Z]) = variableSizeBytes(uint16, c) })
- X
type that can be discriminated by discriminator values of type
D
- D
value type that discriminates
Y
in context ofX
from other types using discriminators ofD
for some typeY
- Source
- Discriminated.scala
- Alphabetic
- By Inheritance
- Discriminated
- Serializable
- Serializable
- Product
- Equals
- AnyRef
- Any
- by ValueEnrichedWithTuplingSupport
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Discriminated(codec: Codec[D])
- new Discriminated(codec: Codec[D], framing: CodecTransformation)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+(other: String): String
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to any2stringadd[Discriminated[X, D]] performed by method any2stringadd in scala.Predef.
- Definition Classes
- any2stringadd
-
def
->[B](y: B): (Discriminated[X, D], B)
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to ArrowAssoc[Discriminated[X, D]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc
- Annotations
- @inline()
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
val
a: Discriminated[X, D]
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to ValueEnrichedWithTuplingSupport[Discriminated[X, D]] performed by method ValueEnrichedWithTuplingSupport in scodec.codecs.
- Definition Classes
- ValueEnrichedWithTuplingSupport
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
bind[Y <: X](discriminator: D)(implicit ev: =:!=[Y, X]): Discriminator[X, Y, D]
Binds the discriminator value
D
to typeY
. -
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
- val codec: Codec[D]
-
def
ensuring(cond: (Discriminated[X, D]) ⇒ Boolean, msg: ⇒ Any): Discriminated[X, D]
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to Ensuring[Discriminated[X, D]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: (Discriminated[X, D]) ⇒ Boolean): Discriminated[X, D]
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to Ensuring[Discriminated[X, D]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean, msg: ⇒ Any): Discriminated[X, D]
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to Ensuring[Discriminated[X, D]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
def
ensuring(cond: Boolean): Discriminated[X, D]
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to Ensuring[Discriminated[X, D]] performed by method Ensuring in scala.Predef.
- Definition Classes
- Ensuring
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
formatted(fmtstr: String): String
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to StringFormat[Discriminated[X, D]] performed by method StringFormat in scala.Predef.
- Definition Classes
- StringFormat
- Annotations
- @inline()
- val framing: CodecTransformation
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
~[B](b: B): (Discriminated[X, D], B)
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to ValueEnrichedWithTuplingSupport[Discriminated[X, D]] performed by method ValueEnrichedWithTuplingSupport in scodec.codecs.
- Definition Classes
- ValueEnrichedWithTuplingSupport
-
def
→[B](y: B): (Discriminated[X, D], B)
- Implicit
- This member is added by an implicit conversion from Discriminated[X, D] to ArrowAssoc[Discriminated[X, D]] performed by method ArrowAssoc in scala.Predef.
- Definition Classes
- ArrowAssoc