Skip to content

Enumerations and Primitive Types

Given the product definition

product {
    Color color
    bool  withStand
    Wheel frontWheel
    Wheel rearWheel
}

We see that the product definition uses different types, such as Color and Wheel.

Enumeration

The type Color is defined as an enumeration of choice values. The specification of the type simply lists all possible choice values.

enumeration Color { Red; Green; Yellow; Blue; White; Black }

The use of ; is optional. Please note that for better clarity, the choices can be listed on separate lines.

enumeration Color {
    Red
    Green
    Yellow
    Blue
    White
    Black
}

Besides the simple listing of choice values, also attributes can be defined for each choice. In the following example, the Wheel type is an enumeration that also includes attributes for each value, such as size in inches and weight in grams.

enumeration Wheel {
    // Attribute definitions
    attribute num/inch size
    attribute num/gr   weight

    // Choice values of the type
    W14 = ( 14 , 550  )
    W16 = ( 16 , 550  )
    W18 = ( 18 , 600  )
    W20 = ( 20 , 650  )
    W22 = ( 22 , 700  )
    W24 = ( 24 , 800  )
    W26 = ( 26 , 900  )
    W28 = ( 28 , 1000 )
}

Here, the choice value W14 is defined with the attributes size=14 and weight=550. The other choice values are defined accordingly.

Please note that attribute values are fixed based on the choice value and cannot be altered during configuration. Additionally, units are used for decoration only and do not automatically apply to calculations or conversions.

Primitive bool

Boolean types can have the values true and false. The following example defines the element withStand of boolean type:

bool withStand

Primitive num

Float values can be defined with a predefined number of digits and a unit text.

num(.number-of-digits)?/?(name-of-unit)? (min max)? name-of-element

For example, the element price is defined having decimal places and the unit Euro.

num.##/Euro 0-2000 price

The declarations of the decimal places, the unit name, and the value range are optional. As with attributes in enumeration definitions, the specified units are used for decoration only and do not automatically apply to calculations or conversions. That way, the following declarations are also valid:

num price1
num 0-2000 price2
num /€ 0-2000 price3

Primitive string (text)

Text types can be defined by the keyword string.

string mySuggestion