Drools manages re-collections and validates a property

With the Drools "mvel" rules, how to iterate over a collection and check a property for each object in the collection?

+6
rules drools mvel
source share
2 answers

Find the forall keyword in the reference guide (follow the documentation on the drools page ).

+6
source share

Here is the code to iterate over the collection of interests inside the Person object and check if one of them contains the field of interests Name: "Running":

 rule "likes running?" when $p : Person() $inter : Interest ( interestName == "Running" ) from $p.interests then System.out.println("I like running too."); end 
+3
source share

All Articles