dynamiclist

Dieser Ausdruck erstellt eine neue Liste, indem ein Ausdruck für jeden Eintrag einer vorhandenen Liste ausgewertet wird.

Die neue Liste enthält pro Eintrag in der vorhandenen Liste einen korrespondierenden Eintrag, wobei die Reihenfolge erhalten bleibt.

Ein Ausdruck dynamiclist gibt Folgendes an:

Ein Ausdruck dynamiclist kann verwendet werden, wenn die Anzahl der Einträge in der gewünschten Liste zur Entwurfszeit nicht bekannt ist (also je nach dem Wert anderer Attribute von Ausführung zu Ausführung variieren kann). Falls die Anzahl der Einträge festgelegt ist (also zur Entwurfszeit bekannt ist), sollte stattdessen der Ausdruck "fixedlist" (siehe fixedlist) verwendet werden.

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

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

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

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

    <Attribute name="pets">
      <type>
        <javaclass name="List">
          <ruleclass name="Pet"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

  </Class>

  <Class name="Pet">
    <Initialization>
      <Attribute name="name">
        <type>
          <javaclass name="String"/>
        </type>
      </Attribute>
    </Initialization>

  </Class>

  <Class name="Household">

    <Attribute name="members">
      <type>
        <javaclass name="List">
          <ruleclass name="Person"/>
        </javaclass>
      </type>
      <derivation>
        <specified/>
      </derivation>
    </Attribute>

    <Attribute name="containsDisabledPerson">
      <type>
        <javaclass name="Boolean"/>
      </type>
      <derivation>
        <any>
          <!-- gets a list of Booleans, corresponding
               to the isDisabled attribute on each
               Person members of this Household   -->
          <dynamiclist>
            <list>
              <reference attribute="members"/>
            </list>
            <listitemexpression>
              <reference attribute="isDisabled">
                <current/>
              </reference>
            </listitemexpression>
          </dynamiclist>
        </any>
      </derivation>
    </Attribute>

    <Attribute name="totalIncomeOfAdultMembers">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <sum>
          <dynamiclist>
            <list>
              <!-- filter the members down to
                   just the adults -->
              <filter>
                <list>
                  <reference attribute="members"/>
                </list>
                <listitemexpression>
                  <compare comparison=">=">
                    <reference attribute="age">
                      <current/>
                    </reference>
                    <Number value="18"/>
                  </compare>
                </listitemexpression>
              </filter>
            </list>
            <listitemexpression>
              <reference attribute="totalIncome">
                <current/>
              </reference>
            </listitemexpression>
          </dynamiclist>
        </sum>
      </derivation>
    </Attribute>

    <Attribute name="memberAges">
      <type>
        <javaclass name="List">
          <javaclass name="Number"/>
        </javaclass>
      </type>
      <derivation>
        <dynamiclist>
          <list>
            <reference attribute="members"/>
          </list>
          <listitemexpression>
            <reference attribute="age">
              <current/>
            </reference>
          </listitemexpression>
        </dynamiclist>
      </derivation>
    </Attribute>

    <Attribute name="youngestAge">
      <type>
        <javaclass name="Number"/>
      </type>
      <derivation>
        <min>
          <reference attribute="memberAges"/>
        </min>
      </derivation>
    </Attribute>

    <!-- get all the pets in the household,
         by joining together each person's
         list of pets -->
    <Attribute name="allPets">
      <type>
        <javaclass name="List">
          <ruleclass name="Pet"/>
        </javaclass>
      </type>
      <derivation>
        <joinlists>
          <!-- a list of list of pets, one
               list for each household
               member -->
          <dynamiclist>
            <list>
              <reference attribute="members"/>
            </list>
            <listitemexpression>
              <reference attribute="pets">
                <current/>
              </reference>
            </listitemexpression>
          </dynamiclist>

        </joinlists>
      </derivation>
    </Attribute>

  </Class>

</RuleSet>