Drools rule iterate collections and verify property
12,727
Solution 1
Look for the forall
keyword in the reference manual (follow documentation on the drools page).
Solution 2
Here's the code for going over the collection of Interests inside a Person object and checking if one of them is contains an interestName field "Running":
rule "likes running?"
when
$p : Person()
$inter : Interest ( interestName == "Running" ) from $p.interests
then
System.out.println("I like running too.");
end
Author by
KALPESH GHAG
Updated on June 04, 2022Comments
-
KALPESH GHAG almost 2 years
With Drools Rules "mvel" how to iterate over a collection and verify a property for each object in the collection?