According to MVEL they’ve added a convenience for
checking the “emptiness” of a value (see: http://mvel.codehaus.org/Value+Tests
)
In MVEL you’d simply write: myMap == empty
This seemed like a MUCH cleaner way to write some of the LHS
of the rules, so I thought I’d try it out.
Given the following rule:
rule "Check Empties - Original"
when
$grabBag : MyGrabBag(someMap != null)
eval
($grabBag.getSomeMap().size() == 0)
then
end
This could be rewritten:
rule "Check Empties - Simple"
when
MyGrabBag(someMap == empty)
then
end
The IDE (Eclipse 3.4.2 w/ Drools plugin) seems to recognize
“empty” is a keyword (it makes it bold), but the drools
compiler in the IDE reports:
BuildError: Unable to create restriction '[VariableRestriction: == empty ]' for
field 'someMap' in the rule 'Check Empties - Simple'
BuildError: Unable to return Declaration for identifier
'empty'
Am I assuming incorrectly that the LHS is fully MVEL
compliant?