On 28/07/2011 08:26, bolsover wrote:
Mark
Thanks for the info - although it was not actually the solution to my
problem, it prompted me to look again at my assertion that there were not
any null values. In actual fact answerData[0] was null ( I should have been
checking for answerData[100]) and this was causing the error.
You modified syntax is much tidier; I'm now using the following format:
$a : Answer(answerData[0] != null&& answerData[0].value_str ==
"Valves")
I'm not sure it's supported in our parser, but I think
we should do it -
either add support for it, or make it implement to the "." accessor.
MVEL supports null safe navigation, which means it'll return false if a
null value is returned from an accessor.
http://mvel.codehaus.org/MVEL+2.0+Property+Navigation
"Sometimes you have property expressions which may contain a null
element, requiring you to create a null-check. You can simplify this by
using the null-safe operator:
user.?manager.name
This is functionally equivalent to writing:
if (user.manager !=null) {return user.manager.name; }else {return null; }"
I doubt there is a time when someone wants a nullpointer to happen. So
maybe we should build this in as default into expressions. I guess the
only time we shouldn't is if people know it will enver be null and don't
want the small overad for the null check.
What do people think?
Mark
This prevents the prior null pointer exception.
Thanks for your input.
David
--
View this message in context:
http://drools.46999.n3.nabble.com/Condition-syntax-to-access-Map-tp320442...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users