CommandBodyJson

How a command's body built in process is written as JSON: with what its class reads (#7534, #7574), so that the body a forward or a command topic carries reads back as the object it was written from, and holds no value its class does not read, which a node of a release that lacks it would refuse as a property its command does not have. Wow writes a command's body from its object through tree, text and bytes: the cluster codec's wire, the ledger's records and the Kotlin client's bodies. A schedule's stored command holds what its class reads, each value as Wow's JSON writes it, and never a write-only value (stored); a message about a command (a decide function's misuse, the test DSL's differences) writes it with Wow's JSON, which leaves its write-only values out. The test DSL compares commands as written here.

  • Every property the class reads is written, a write-only one (@JsonProperty(access = WRITE_ONLY)) included, which Wow's JSON leaves out of everything else it writes; a Kotlin private val so marked is written from its field. A schedule refuses a command that holds one that is not null, which pruned reports: its stored command never holds one.

  • A property the class does not read is left out: a getter with no field, setter or constructor parameter behind it (a computed property, annotated or not, a lazy one, a computed @AggregateId, which the command's ref carries), a read-only one, one its @JsonIgnoreProperties lets be written and not read, an attribute a writer appends.

  • A property its reader reads as something else than a value is written: a polymorphic value's type id, an existing property of it (@JsonTypeInfo(include = EXISTING_PROPERTY) on its class, computed or read-only), or one its holder writes beside it (EXTERNAL_PROPERTY); an identity a property generator names (@JsonIdentityInfo); and a getter the class merges what it reads into (@JsonMerge).

  • Where the writer cannot tell what a class reads, it leaves nothing out of it but a read-only property: a class read by a builder, a deserializer or a converter of its own (@JsonDeserialize(builder|using|converter)) or a creator Jackson resolves as delegating, with a mode or without; a value its property's own deserializer or converter reads, or, of a container, its values (@JsonDeserialize(using|converter|contentUsing|contentConverter) on the property). A value whose holder declares its type id as an existing property of it (@JsonTypeInfo(include = EXISTING_PROPERTY) on the property), whose class does not say which getter that is, is written whole with its read-only properties too, the type id among them: in this one shape a computed or read-only property travels, so a node of the release before whose class lacks it refuses it, as main wrote every shape.

  • A null is written as null and a default as its value, unless the class says otherwise (@JsonInclude): a nullable property whose default is not null reads a missing value as that default.

  • A value written by a serializer of its own (@JsonSerialize(using = …), @JsonValue) is written as it writes it, and the entries of a @JsonAnyGetter as it gives them, which its @JsonAnySetter reads, or, with none, which a node refuses.

A property the class reads and has no getter for (a Java setter with no getter, a Kotlin private val constructor parameter that is not write-only), or one it ignores, cannot be carried: set in code, its value stays where the command was built.

Types

Link copied to clipboard
class Pruned(val tree: JsonNode, val writeOnly: List<String>, val unpaired: List<String>)

A body Wow's JSON wrote, pruned to what its class reads (pruned): the tree, each of whose values is the value Wow's JSON wrote at its path or the constant null, and the paths where the two writings disagree, each a path from the body (a property by its name after a ., an item by its position, lines[0].pin).

Functions

Link copied to clipboard
fun bytes(body: Any): ByteArray

body as the JSON bytes this writer writes.

Link copied to clipboard
fun pruned(written: JsonNode, shown: JsonNode): CommandBodyJson.Pruned

shown, a body as Wow's JSON writes it, pruned to the paths of written, the same body as this writer writes it: what the body's class reads, each value as Wow's JSON wrote it (Pruned.tree). It never takes a value from written: a path only written holds is the constant null in the tree, so a write-only value is never in it, and a write-only value that held null reads back as null, not as its default. Paths are compared below the same paths, so a write-only value is found wherever it is held, below a value of a shape no schema states included.

Link copied to clipboard
fun stored(body: Any, shown: JsonNode): CommandBodyJson.Pruned

body as a schedule stores it (pruned): shown, the tree of the text Wow's JSON writes of body, pruned to the paths of this writer's text of it, read back as shown was, so their numbers are of one kind.

Link copied to clipboard
fun text(body: Any): String

body as the JSON text this writer writes.

Link copied to clipboard
fun tree(body: Any): JsonNode

body as the JSON tree this writer writes.