Set Property
Stores an unordered set of unique items.
See properties page to see which property types it can contain. Property definitions need to be required and values can thus not be null.
- Kotlin Definition:
SetDefinition<T>T is for type of value definition - Kotlin Value:
Set - Maryk Yaml Definition:
Set
Usage options
Section titled “Usage options”- Value
Validation Options
Section titled “Validation Options”required- default truefinal- default falseminSize- default unset. Minimum size of setmaxSize- default unset. Maximum size of set
Other options
Section titled “Other options”default- the default value to be used if value was not set.valueDefinition- definition of values contained
Examples
Section titled “Examples”Example of a Set property definition for use within a Model
val names by set( index = 1u, required = false, final = true, valueDefinition = StringDefinition())Example of a separate Set property definition
val def = SetDefinition( required = true, final = true, valueDefinition = StringDefinition())Operations
Section titled “Operations”Set can be applied with Set operations through SetPropertyChange to check
or change the contents. It can be defined with a set with addValues or a set with
deleteValues. The current value can be compared against valueToCompare
Kotlin example on a model with a set containing strings.
SetChange( Model { setOfStrings::ref }.change( addValues = setOf("three", "four"), deleteValues = setOf("one", "two") ))Indexing set values
Section titled “Indexing set values”Set properties can be indexed on any set value with refToAny() (set.* in string notation).
Example:
object ExampleModel : RootDataModel<ExampleModel>( indexes = { listOf( ExampleModel { tags.refToAny() } ) }) { val tags by set( index = 1u, required = false, valueDefinition = StringDefinition() )}Byte representation
Section titled “Byte representation”Depends on the specific implementation. The values are stored in their representative byte representation.
Transport Byte representation
Section titled “Transport Byte representation”Sets can be encoded in 2 ways, normal tag/value pairs and packed mode.
In tag/value pairs the values are encoded with a tag referring to the set and the value as their normal transport byte representation.
Tag value pairs
Section titled “Tag value pairs”T V T V T V T V T V
T= Tag + wiretypeV= Value encoded as LENGTH_DELIMITED or START_GROUP (Until end group)
In Packed encoding multiple values are encoded with one tag representing the specific set and a Length Delimiter. This is only available and is automatically applied for values of BIT_32, BIT_64 or VAR_INT wiretype encoding since the sizes of each item are known.
Packed encoding
Section titled “Packed encoding”T L V V V V V
T= Tag + wiretype of Length DelimitedL= VarInt with LengthV= Value encoded as BIT_32, BIT_64 or VAR_INT