Search code examples
javadroolsrulesrule-engine

forall always evaluates to be true [Drools]


I have a class Application, within which there is a list of instances of CallPhones.

class Application() {
      List<CallPhones> callPhonesList;
      ...
}

class CallPhones() {
      Integer callTimes;
      ...
}

I want to fire the rule when callTimes of all instances larger than 10. Here is the rule:

rule "Application eligible"
    when
        app : Application()
        forall(CallPhones(callTimes > 10))
    then 
        // application is eligible
end

Strangely, the rule always fires, even when there's an instance with callTimes being 5. I also tried answer of this question, but got no help. Any ideas?


Solution

  • It should be

    rule "Application eligible"
        when
            app : Application()
            forall($temp:CallPhones(callUserTimes > 10) from app.callPhoneList)
        then 
            // application is eligible
    end