使用多个数据对象创建具有复杂条件的规则

Creating rules having complex conditions using multiple data objects

假设我有两个数据对象 PersonAddress。 Person 对象具有 namegender 字段,Address 对象具有 citystate 字段。现在我想根据这种情况采取一些行动:

when
    (person.name == 'jayram' && address.city == 'barhiya') || 
    (person.gender == 'M' && address.state == 'bihar')
then
    do something

如何在 drools 规则文件中完成此操作?

也许这应该是解决方案:

package com.sample

dialect "mvel"

import com.sample.Person;
import com.sample.Address;

rule "Hello World"
    when
        person : Person( status == Message.HELLO)
        Address((person.name == 'jayram' && city == 'barhiya') ||
 (person.gender == 'M' && state == 'bihar'))
    then
        // Do something
end