dehiker dehiker - 5 months ago 23
Java Question

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?

Answer

It should be

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