The match keyword deals with hierarchical property values.
The match predicates are used to handle hierarchical property values.
Any expression involving objects
rule property access value match string value; rule property access value match up string value; rule property access value match updown string value; rule property access value match down string value;
The match predicates have two arguments: the first argument is an access to a rule hierarchical property. To make this access possible, you must define the rule property in a propertydefinition section. The second argument is a string.
This example uses the following element:
The Geography property, a hierarchical property that has been defined as follows:
hierarchy Geography { "North"
{ "USA" { "California" { "San Francisco" } "Texas" { "Houston" "Paris" } }
"Europe" { "France" { } "Germany" } }
}
The location property, a rule property of type Geography,
The ?rule variable
You can use the following keywords:
?rule.?location match "California" returns true if the location value is equal to California.
?rule.?location match up "California" returns true if the location value is one of the values from the hierarchy root to California node.
?rule.?location match down "California" returns true if the location value is one of the values from the "California" node to the hierarchy leaves (children of California node).
?rule.?location match updown "California" returns true if the location value either matches up or matches down California.
In this example, the rule task selects all the rules except the rule France.
hierarchy Geography { "North"
{ "USA" { "California" { "San Francisco" } "Texas" { "Houston" "Paris" } }
"Europe" { "France" { } "Germany" } }
}
propertydefinition { Geography location; }
rule usa { property location = "USA"; when { ... } then { ... } }
rule california { property location = "California"; when { ... } then { ... } }
rule france { property location = "France"; when { ... } then { ... } }
ruletask main
{
body = dynamicselect()
{
Collection rules = collect IlrRule(?this.?location match up "California")
in getRuleset().getAllRules();
return rules;
}
}