The rule is fired once per each object matching your condition. So, you'll need to access the Data object directly as $data.val
and data.text
If you need/want the objects in a list, you can use collect
for that. Then your rule would be like
rule "Demo Rule"
when
$dataList : ArrayList() from collect( Data (val == 1 || val == 2) )
then
System.out.println($dataList);
end