[rules-users] Condition syntax to access Map

Mark Proctor mproctor at codehaus.org
Wed Jul 27 15:32:16 EDT 2011


On 27/07/2011 19:45, bolsover wrote:
> I'm struggling with the syntax to access a mapped object - hoping that
> someone can help with this..
>
> I have the following condition in a rule:
>
> $a : Answer(getAnswerData().get(0).getValue_str() == "Valves")
try Drools 5.2 and you should be able to do
Answer( answerData[0].value_str == "valves" )

Mark
>
> Answer is a pojo where answerData is a Map<Integer, AnswerData>
> object.
> AnswerData is also a pojo and has a String variable value_str.
>
> Rule containing this condition complies but I get the following error when I
> fireAllRules
>
> [Error: null pointer or function not found: getValue_str]
> [Near : {... getAnswerData().get(0).getValu ....}]
>               ^
> [Line: 1, Column: 1]
>
> org.mvel2.optimizers.impl.refl.ReflectiveAccessorOptimizer.getMethod(ReflectiveAccessorOptimizer.java:997)
>
> The method getValue_str() does exist in AnswerData as does getAnswerData()
> in Answer and there are not any null values.
>
> I'm assuming that autoboxing will correctly interpret .get(0) as an Integer
> object.
>
>
> Any ideas??
>
>
>
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/Condition-syntax-to-access-Map-tp3204429p3204429.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>





More information about the rules-users mailing list