BlockML Documentation

Enum Types

A closed set of named members

EnumType is its own ValueType branch for closed enum types — a finite set of named literal values whose stored property value is member identity, not a struct payload.

Why EnumType is not a StructType

A PrimitiveType defines an open value domain, a StructType defines shape through its properties, and an EnumType defines a closed set of members whose property value is the member's id plus its EnumType — never a struct payload.

Members as catalog Block instances

Each allowed member is a Block instance of the EnumType in its values aggregation, carrying a mandatory bml:id as the reference token — an EnumType may also declare its own properties, filled per member as catalog metadata, analogous to fields on a Java enum constant.

Declaring a small closed enum

A small EnumType declares its allowed members in values, each identified by a distinct bml:id.

<!-- Direction is a closed EnumType with two catalog members, North and South -->
<acme:Direction xmlns="http://blockml.org/bml"
  xmlns:acme="com.acme.example"
  xmlns:type="org.blockml.bml.type">

  <baseType>
    type:EnumType
  </baseType>
  <values>
    <acme:Direction bml:id="North" />
    <acme:Direction bml:id="South" />
  </values>
</acme:Direction>

A Property typed with acme:Direction may take only one of the two ids shown in values, North or South — any other token fails validation, since the closed set is defined entirely by this catalog.

What to carry into the next pages

After this page, readers should be able to define a closed enum and use its literal values, keeping in mind that suggestions never apply to EnumType properties.

Continue with primitive entities