Hi - I am a Drools newbie and I apologize in advance if the answer to my question is intuitively obvious to the casual user.<br><br>I have an object that has two fields: location(there are more than 50 locations) and age. I am having difficulty building clean rules for the following pseudo-code<br>
<br><br>// Rule One<br>if(location == "A") {<br> if(age > 60)<br> do_something();<br>}<br>// Rule Two<br>else if(location == "B") {<br> if(age > 70)<br> do_something();<br>}<br>// Rule Three<br>
else if(location == "C") {<br> if(age > 80)<br> do_something();<br>}<br>// Rule Four<br>else {<br> if(age > 65)<br> do_something();<br>}<br><br>The issue comes with Rule Four. How do I avoid writing the rule so that I don't have to say (location!="A"&&location!="B"&&location!="C") ? I also don't want to have to write an explicit rule for every possible location.<br>
<br>I considered an activation-group with salience to have the rules executed in order, but the problem is that if rules 1-3 do not fire, then rule 4 fires for all locations - I can get a hit if location=="C" and age==70.<br>
<br>Is it possible to have a 'Map' and do something like (age>map.get(location)) ? I could live with creating a map with all possible locations for key, although I'd rather not go this route.<br><br>This problem is typical for the types of rules I'll be writing ... there can be completely different sets of rule criteria depending on location.<br>
<br><br>Thanks in advance for your suggestions and your patience.<br>