jeudi 6 juillet 2017

Drools - Running a rule with an empty object

I'm trying to write a rule to calculate prices for an insurance product based on conditions. In the 'when' I'm using an object called AdditionalDriver, which contains the details for drivers other than the policy holder. From this, different prices can be calculated based on whether the additional driver is a parent, friend, spouse etc. See below:

when AdditionalDriver($relToProp : relationToProposer) then String relToProp = $relToProp;

if(!relToProp.equals("P"))
{
    //prices
}

end

"P" = parent.

This rule works when an additional driver has been added. However, if there is no additional driver, then the object is empty, and so the rule does not run. What do I need to do to get this rule to run, even when the object is empty?

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire