BlockML Documentation

Multiplicity and Collections

Multiplicity is a bracket, not a type

BlockML has no separate Array type — bracket notation such as Integer[] is a postfix operation on a type expression, metadata on the reference rather than an intrinsic property of the named ValueType.

Reading the bracket forms

A bare type such as Integer means exactly one; Integer[] means zero to n, equivalent to Integer[0..n]; and forms such as Integer[3] or Integer[1..5] fix or bound the count explicitly.

Nesting requires explicit grouping

Because multiplicity applies to any type expression including one that already carries multiplicity, a collection of collections needs explicit grouping — (Integer[])[] — since Integer[][] leaves the binding of each bracket ambiguous and is not supported.

An aggregation of a bounded collection

An aggregation's type attribute can bound how many children it holds using a ranged multiplicity bracket, directly on the Block type it aggregates.

<!-- "items" holds between 1 and 5 acme:Widget instances -->
<acme:Basket xmlns="http://blockml.org/bml"
  xmlns:acme="com.acme.example"
  xmlns:core="org.blockml.bml.core">

  <baseType>
    core:Block
  </baseType>
  <aggregations>
    <items type="acme:Widget[1..5]" />
  </aggregations>
</acme:Basket>

The 1..5 range on items is metadata on the type reference itself — Widget's own definition is unaffected by how many instances any particular aggregation happens to bound. A Basket with no items, or with six, would both fail validation against this bracket.

What to carry into the next pages

After this page, readers should be able to read a multiplicity bracket and place it correctly in a type expression, closing out the member model before Constraints introduces declarative validation rules.

Continue with constraints