trait MutableSchemaBasedValueBuilder[Target, Context] extends AnyRef
Base trait for mutable builders producing a value based on a schema, such as codec decoders.
The implementation is stack safe and consists of a series of invocations of the protected methods the trait defines. Maintaining the state of the builder, such as stream position etc. is the responsibility of the implementation class via mutable state.
The Target type parameter is the base type for the generated values - this in many cases can be Any but potentially could be used to track errors in value level as well - although failure in the context handler manipulation methods cannot be expressed this way.
The Context type parameter is a use-case dependent type that is managed in a stack during the execution of the builder. The implementation can generate new context values for the value's subtrees and it can be used to track local state required for gathering all information for the value to be created. The current context value is also propagated to any exception thrown so it can be used to provide detailed location information for decoder errors.
- Alphabetic
- By Inheritance
- MutableSchemaBasedValueBuilder
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def createDictionary(context: Context, schema: Map[_, _], values: Chunk[(Target, Target)]): Target
Creates the dictionary value from the chunk of key-value pairs
Creates the dictionary value from the chunk of key-value pairs
- Attributes
- protected
- abstract def createDynamic(context: Context): Option[Target]
Creates a Dynamic value.
Creates a Dynamic value. If the returned value is None, it indicates that the builder does not have any built-in support for Dynamic values, and it will be built using Dynamic's schema.
- Attributes
- protected
- abstract def createEither(context: Context, schema: Either[_, _], value: Either[Target, Target]): Target
Create the either value from an inner value
Create the either value from an inner value
- Attributes
- protected
- abstract def createEnum(context: Context, cases: Chunk[Case[_, _]], index: Int, value: Target): Target
Creates an enum value from the read constructor value
Creates an enum value from the read constructor value
- Attributes
- protected
- abstract def createOptional(context: Context, schema: Optional[_], value: Option[Target]): Target
Creates the optional value from the inner value
Creates the optional value from the inner value
- Attributes
- protected
- abstract def createPrimitive(context: Context, typ: StandardType[_]): Target
Creates a primitive value of the given standard type
Creates a primitive value of the given standard type
- Attributes
- protected
- abstract def createRecord(context: Context, record: Record[_], values: Chunk[(Int, Target)]): Target
Creates a record value from the gathered field values
Creates a record value from the gathered field values
- Attributes
- protected
- abstract def createSequence(context: Context, schema: Sequence[_, _, _], values: Chunk[Target]): Target
Creates the sequence value from the chunk of element values
Creates the sequence value from the chunk of element values
- Attributes
- protected
- abstract def createSet(context: Context, schema: Set[_], values: Chunk[Target]): Target
Creates the set value from the chunk of element values
Creates the set value from the chunk of element values
- Attributes
- protected
- abstract def createTuple(context: Context, schema: Tuple2[_, _], left: Target, right: Target): Target
Creates the tuple from the constructed first and second values
Creates the tuple from the constructed first and second values
- Attributes
- protected
- abstract def fail(context: Context, message: String): Target
Fail the builder with the given message
Fail the builder with the given message
- Attributes
- protected
- abstract def finishedCreatingOneDictionaryElement(context: Context, schema: Map[_, _], index: Int): Boolean
Called after constructing a single dictionary element.
Called after constructing a single dictionary element. The context is the context of the whole dictionary. If the returned value is true, a next element will be read otherwise the dictionary is completed and createDictionary is called.
- Attributes
- protected
- abstract def finishedCreatingOneSequenceElement(context: Context, schema: Sequence[_, _, _], index: Int): Boolean
Called after constructing a single sequence element.
Called after constructing a single sequence element. The context is the context of the whole sequence. If the returned value is true, a next element will be read otherwise the sequence is completed and createSequence is called.
- Attributes
- protected
- abstract def finishedCreatingOneSetElement(context: Context, schema: Set[_], index: Int): Boolean
Called after constructing a single set element.
Called after constructing a single set element. The context is the context of the whole set. If the returned value is true, a next element will be read otherwise the set is completed and createSet is called.
- Attributes
- protected
- abstract val initialContext: Context
The initial (top-level) context value
The initial (top-level) context value
- Attributes
- protected
- abstract def startCreatingDictionary(context: Context, schema: Map[_, _]): Option[Context]
The next value to build is a dictionary.
The next value to build is a dictionary. If the returned value is None, the builder creates an empty dictionary, otherwise it calls startCreatingOneDictionaryElement, startCreatingOneDictionaryValue and finishedCreatingOneDictionaryElement for each element with the returned context.
- Attributes
- protected
- abstract def startCreatingEither(context: Context, schema: Either[_, _]): Either[Context, Context]
The next value to be created is an either value with the given schema.
The next value to be created is an either value with the given schema. Similarly to optional values, this method is responsible for gathering enough information to decide whether the created value will be a Left or a Right. The result value represents this, and for each case allows specifying a context that will be used to create the inner value.
- Attributes
- protected
- abstract def startCreatingEnum(context: Context, cases: Chunk[Case[_, _]]): (Context, Int)
The next value to build is an enum with the given schema
The next value to build is an enum with the given schema
- Attributes
- protected
- abstract def startCreatingOneDictionaryElement(context: Context, schema: Map[_, _]): Context
Called before constructing a next dictionary element.
Called before constructing a next dictionary element. The returned context is used for constructing that single element's key.
- Attributes
- protected
- abstract def startCreatingOneDictionaryValue(context: Context, schema: Map[_, _]): Context
Called after the key of a single element was created, before the value gets created.
Called after the key of a single element was created, before the value gets created. The returned context is for constructing the element's value part.
- Attributes
- protected
- abstract def startCreatingOneSequenceElement(context: Context, schema: Sequence[_, _, _]): Context
Called before constructing a next sequence element.
Called before constructing a next sequence element. The returned context is used for constructing that single element.
- Attributes
- protected
- abstract def startCreatingOneSetElement(context: Context, schema: Set[_]): Context
Called before constructing a next set element.
Called before constructing a next set element. The returned context is used for constructing that single element.
- Attributes
- protected
- abstract def startCreatingOptional(context: Context, schema: Optional[_]): Option[Context]
The next value to be created is an optional value.
The next value to be created is an optional value. If the result is None, the optional value created will be None. If it is a context, that context will be used to create the optional value.
- Attributes
- protected
- abstract def startCreatingRecord(context: Context, record: Record[_]): Context
The next value to build is a record with the given schema
The next value to build is a record with the given schema
- Attributes
- protected
- abstract def startCreatingSequence(context: Context, schema: Sequence[_, _, _]): Option[Context]
The next value to build is a sequence.
The next value to build is a sequence. If the returned value is None, the builder creates an empty sequence, otherwise it calls startCreatingOneSequenceElement and finishedCreatingOneSequenceElement for each element with the returned context.
- Attributes
- protected
- abstract def startCreatingSet(context: Context, schema: Set[_]): Option[Context]
The next value to build is a set.
The next value to build is a set. If the returned value is None, the builder creates an empty set, otherwise it calls startCreatingOneSetElement and finishedCreatingOneSetElement for each element with the returned context.
- Attributes
- protected
- abstract def startCreatingTuple(context: Context, schema: Tuple2[_, _]): Context
The next value to be created is a tuple with the given schema.
The next value to be created is a tuple with the given schema. The returned context is used to construct the first element of the tuple.
- Attributes
- protected
- abstract def startReadingField(context: Context, record: Record[_], index: Int): Option[(Context, Int)]
Called for each field of a record.
Called for each field of a record. The resulting tuple is either None indicating there are no more fields to read, or it contains an updated context belonging to the field and the next field's index in the schema. This allows the implementation to instantiate fields in a different order than what the schema defines.
The index parameter is a 0-based index, incremented by one for each field read within a record.
- Attributes
- protected
- abstract def startReadingSecondTupleElement(context: Context, schema: Tuple2[_, _]): Context
Called after finished constructing the first element, before constructing the second.
Called after finished constructing the first element, before constructing the second. The returned context is used to construct the second value.
- Attributes
- protected
- abstract def transform(context: Context, value: Target, f: (Any) => Either[String, Any], schema: Schema[_]): Target
Transforms a value with the given function that can fail.
Transforms a value with the given function that can fail. Making this customizable allows encoding the failure in Target.
- Attributes
- protected
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def create[A](schema: Schema[A]): Target
Create a value of type A with the provided schema using this builder
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- 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
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()