I have an Object in working memory. This object has an ArrayList of Integer
objects. I am trying to create a rule that will count all occurrences of
Integers in this ArrayList that are non-zero and then calculate the sum of
all the Integers in the ArrayList and then check the total against a range.

I understand how to count the non-zero occurrences but I am at a complete
loss as to how to calculate the sum of the Integer objects in the ArrayList.

Here is the rule I have thus far
rule "Rule 1"
        dialect "java"
        when
                $mo : MyObject( )
                $i : ArrayList ( ) from collect ( Number( intValue > 0 ) from
$mo.getNumbers() )
                $total : Number(  ) from accumulate ???
        then
                System.out.println("Rule 1: i.size() = " + $i.size());
                System.out.println("Rule 1: total = " + $total);
end

I have been unsuccessful in finding a post that deals with how to fill in
the ??? portion of my rule. My apologies in advance if I happen to miss such
a post.

Any help is greatly appreciated.

Regards,
Gerald
-- 
View this message in context: 
http://www.nabble.com/accumulate---sum-and-ArrayList-tp16033216p16033216.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to