DynamicValue

com.digitalasset.transcode.schema.DynamicValue
object DynamicValue

Dynamic types are represented by opaque types to reduce memory allocations during transformation from one codec to another.

There are 3 kinds of possible dynamic values:

  • ADTs: records or variants. These are fixed in size, and are containers to other types. These types are addressable and have identifiers. There are special cases: enums and wrapped types.
  • Traversables: lists, maps, optionals. These are variable in size and are containers to other types.
  • Primitives: primitive scalar types.

Codecs and code-generations should be constructed in such a way that ADTs and Traversables expecting other underlying dynamic values in processing routines should know exactly what underlying values they expect. The unwrapping of dynamic value and casting should be safe then. SchemaProcessor takes care of constructing a tree of type processors and injects correct underlying processors where needed. See examples of how this is used in codecs: JSON and Grpc and code-gens: Java and Scala.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Type members

Types

opaque type Adt
opaque type Bool

Boolean

Boolean

Attributes

opaque type ContractId

Contract ID

Contract ID

Attributes

opaque type Date

Local date. Number of dates since epoch (1 Jan 1970).

Local date. Number of dates since epoch (1 Jan 1970).

Attributes

opaque type Enumeration

ADT, Sum type - special case of sum type with parameter-less constructors.

ADT, Sum type - special case of sum type with parameter-less constructors.

Attributes

opaque type GenMap

Map with arbitrarily typed keys and values. Codecs should maintain stable order of key-value entries if possible.

Map with arbitrarily typed keys and values. Codecs should maintain stable order of key-value entries if possible.

Attributes

opaque type Int64

8-byte integer

8-byte integer

Attributes

opaque type List

Sequence of elements

Sequence of elements

Attributes

opaque type Numeric

Numeric type with precision. Represented as a String

Numeric type with precision. Represented as a String

Attributes

opaque type Optional

Optional element

Optional element

Attributes

opaque type Party

Party

Party

Attributes

opaque type Primitive
opaque type Record

ADT, Product type. Field values have to be in the same order os in the defining type. Field names here are not necessary, as codecs knows about field names at the time of construction

ADT, Product type. Field values have to be in the same order os in the defining type. Field names here are not necessary, as codecs knows about field names at the time of construction

Attributes

opaque type Text

Text

Text

Attributes

opaque type TextMap

Map with String keys. Codecs should maintain stable order of key-value entries if possible.

Map with String keys. Codecs should maintain stable order of key-value entries if possible.

Attributes

opaque type Timestamp

Timestamp. Number of microseconds (10^-6^) since epoch (midnight of 1 Jan 1970) in UTC timezone.

Timestamp. Number of microseconds (10^-6^) since epoch (midnight of 1 Jan 1970) in UTC timezone.

Attributes

opaque type Traversable
opaque type Type
opaque type Unit

Unit

Unit

Attributes

opaque type Variant

ADT, Sum type. Contains constructor's ordinal index and a wrapped value.

ADT, Sum type. Contains constructor's ordinal index and a wrapped value.

Attributes

Value members

Concrete methods

def Bool(value: Boolean): Bool
def Date(value: Int): Date
def Enumeration(ctorIx: Int): Enumeration
def Int64(value: Long): Int64
def Numeric(value: String): Numeric
def Party(value: String): Party
def Record(fields: Array[DynamicValue]): Record
def Record(fields: DynamicValue*): Record
def Text(value: String): Text
def Timestamp(value: Long): Timestamp
def Variant(ctorIx: Int, value: DynamicValue): Variant
def withRecordIterator[A](dv: DynamicValue, expectedFieldCount: Int, code: Function[Iterator[DynamicValue], A]): A

Concrete fields

val Unit: Unit

Extensions

Extensions

extension (value: DynamicValue)
def checkRecordSize(maxSize: Int): Unit
def recordIteratorPadded(expectedFieldCount: Int): Iterator[DynamicValue]
extension [B](value: DynamicValue)
def variantIx: Int
extension (value: DynamicValue)
extension (value: DynamicValue)
extension (value: DynamicValue)
extension (value: DynamicValue)
def unit: Unit
extension (value: DynamicValue)
def bool: Boolean
extension (value: DynamicValue)
def text: String
extension (value: DynamicValue)
def int64: Long
extension (value: DynamicValue)
extension (value: DynamicValue)
extension (value: DynamicValue)
def date: Int
extension (value: DynamicValue)
def party: String
extension (value: DynamicValue)