Skip to main content

Enum Types

Enum Types are an experimental extension of the elements metamodel. They allow you to create ValueTypes for which the possible values are enumerated in the model.

Enum-types are split into 2 expander bundles. Use the enum-type-rest-expanders if you want to integrate with the rest-expanders.

net.democritus.experimental.enumtypes:enum-type-expanders::0.0.2 net.democritus.experimental.enumtypes:enum-type-rest-expanders::0.0.2

Defining EnumType

EnumTypes are defined in a Component. In the Component model directory, add your EnumType models under valueTypes.

E.g. this describes a FileChangeType enum:

<valueType name="FileChangeType" type="enumTypeElements::EnumType">
<packageName>org.normalizedsystems.quests</packageName>
<values>
<enumValueType name="ADD">
<description>File was created</description>
</enumValueType>
<enumValueType name="MODIFY">
<description>File was updated</description>
</enumValueType>
<enumValueType name="DELETE">
<description>Files was removed</description>
</enumValueType>
<enumValueType name="RENAME">
<description>File was moved or renamed</description>
</enumValueType>
<enumValueType name="COPY">
<description>File is a copy from another file</description>
</enumValueType>
</values>
</valueType>

The ValueType can then be used as target for ValueField#type:

<field name="changeType">
<valueField>
<type name="FileChangeType"/>
</valueField>
</field>

You can use the defaultValue option on a Field to define one of the enums as initial value:

<field name="changeType">
<valueField>
<type name="FileChangeType"/>
</valueField>
<options>
<defaultValue>MODIFY</defaultValue>
</options>
</field>

Known Issues

  • EnumTypes do not work with the isRequired option of the REST-expanders on the enum field. This option generates a test that does not compile, because it is not yet implemented for ValueTypes.
  • When changing a field to the new EnumType, also update the commands for the REST API's, otherwise it will not compile.
  • You will have to use at least version 1.15.9 of the micro-radiant, otherwise your project will not be able to load.

Missing Integrations

  • Angular-expanders
  • Knockout UI