10 Feb 06:04
problem binding variable to map value
Ming Fang <mingfang <at> mac.com>
2012-02-10 05:04:32 GMT
2012-02-10 05:04:32 GMT
Below is a very simple rule that binds a variable to a map value...
rule "how many times is map.get() called?"
when
p:Parameter(
$value:tags[1]==1,
$value == 1,
$value != 2,
$value != null,
$value in ("1","2")
)
then
System.out.println("value=" + $value);
end
The problem is map.get() is called 6 times when executing this rule using a Stateless session.
To test this I implement a mock Map that the get(key) simply returns the key.
So in this example tags[1] return 1.
And in the get() I simply print a test message to see how many times it's been called.
Here is the sequence...
1x = tags[1]
2x = tags[1] == 1
3x = $value == 1
4x = $value != 2
5x = $value != null
and most surprisingly none for $value in ("1","2")
but
6x == System.out.println("value="+$value)
(Continue reading)
RSS Feed