match
match keyword deals with hierarchical
property values.
Purpose
The match predicates
are used to handle hierarchical property values.
Context
Any expression involving objects
Syntax
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;
Description
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.
Example
This example uses the following element:
The
Geographyproperty, a hierarchical property that has been defined as follows:hierarchy Geography { "North" { "USA" { "California" { "San Francisco" } "Texas" { "Houston" "Paris" } } "Europe" { "France" { } "Germany" } } }The
locationproperty, a rule property of typeGeography,The
?rulevariable
You can use the following keywords:
- match
?rule.?location match "California"returnstrueif the location value is equal toCalifornia.- match up
?rule.?location match up "California"returnstrueif the location value is one of the values from the hierarchy root toCalifornianode.- match down
?rule.?location match down "California"returnstrueif the location value is one of the values from the "California" node to the hierarchy leaves (children ofCalifornianode).- match updown
?rule.?location match updown "California"returnstrueif the location value either matches up or matches downCalifornia.
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;
}
}