fixedlist

Creates a new list from items known at rule set design time.

The fixedlist expression specifies:

The created list will contain its members in the order listed in the rule set.

Tip: The members element may contain 0, 1 or many child elements.

However, if the fixedlist is contained within a list processing operation but only specifies 0 or 1 list members, the CER rule set validator will issue a warning, indicating that the list may be unnecessary.

If you need to create a list where the number of items in the list is not known at design time, consider using dynamiclist instead.

<?xml version="1.0" encoding="UTF-8"?>
<RuleSet name="Example_fixedlist"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation=
"http://www.curamsoftware.com/CreoleRulesSchema.xsd">
  <Class name="Person">

    <!-- The pets owned by this Person -->
    <Attribute name="pets">
      <type>
        <javaclass name="List">
          <ruleclass name="Pet"/>
        </javaclass>
      </type>
      <derivation>

        <!-- A fixed list of Pets -->
        <fixedlist>
          <listof>
            <ruleclass name="Pet"/>
          </listof>
          <members>
            <!-- Every Person has exactly two pets,
                 Skippy and Lassie -->
            <create ruleclass="Pet">
              <String value="Skippy"/>
              <String value="Kangaroo"/>
            </create>
            <create ruleclass="Pet">
              <String value="Lassie"/>
              <String value="Dog"/>
            </create>
          </members>
        </fixedlist>
      </derivation>
    </Attribute>


    <Attribute name="isEntitledToBenefits">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <all>
          <!-- A fixed list of Boolean conditions -->
          <fixedlist>
            <listof>
              <javaclass name="Boolean"/>
            </listof>
            <members>
              <!-- Must be an adult -->
              <compare comparison=">=">
                <reference attribute="age"/>
                <Number value="18"/>
              </compare>
              <!-- Must be resident in the state -->
              <reference attribute="isResidentInTheState"/>
              <!-- Must have income under the threshold for benefits
 -->
              <compare comparison="&lt;">
                <reference attribute="totalIncome"/>
                <Number value="100"/>
              </compare>
            </members>
          </fixedlist>

        </all>

      </derivation>
    </Attribute>

    <Attribute name="totalIncome">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <!-- A pointless sum of one item -
             the CER rule set validator will warn that this
             fixedlist may be unnecessary. -->
        <sum>
          <fixedlist>
            <listof>
              <javaclass name="Number"/>
            </listof>
            <members>
              <!-- Sum up only the earned income -->
              <reference attribute="earnedIncome"/>
            </members>
          </fixedlist>

        </sum>

      </derivation>
    </Attribute>

    <Attribute name="earnedIncome">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>


    <Attribute name="isResidentInTheState">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="age">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

  </Class>

  <Class name="Pet">

    <Initialization>

      <Attribute name="name">
        <type>
          <javaclass name="String"/>
        </type>
      </Attribute>

      <Attribute name="species">
        <type>
          <javaclass name="String"/>
        </type>
      </Attribute>

    </Initialization>

  </Class>

</RuleSet>