流口水中的嵌套规则 [英] Nested Rules In Drools

查看:103
本文介绍了流口水中的嵌套规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.drl文件,其中包含100多个规则.大约有40条规则,例如规则"1",大约35条规则,例如规则"2",其余的规则,例如规则"3".

I have a .drl file which contains more than 100 rules. There are approximately 40 rules like rule "1", some 35 like rule "2" and rest are like rule "3".

rule "1"
    when
        m: MyBeanClass( something1 == "train" && something2 == somevalue2)
    then
        m.setSomeThing(someOtherValue);
        update(m);
    end

rule "2"
    when
        m: MyBeanClass( something1 == "bus" && something2 == somevalue2)
    then
        m.setSomeThing(someOtherValue);
        update(m);
    end

rule "3"
    when
        m: MyBeanClass( something1 == "car" && something2 == somevalue2)
    then
        m.setSomeThing(someOtherValue);
        update(m);
    end

在触发所有规则时,所有规则都会执行,我不希望.如果"something1"不等于"train",那么我希望执行流程直接转到第41条规则,就像这里的"2"规则.

On firing all rules, all the rules will get executed, which I do not want. If "something1" is not equal to "train", then I want the execution flow to directly go to the 41st rule which is like the rule "2" here.

请提出建议.

谢谢, 沙杜尔

推荐答案

我将为"car","bus"和"train"设置三个范围规则,以设置一个值,然后使用41条规则获取该范围值并对其进行操作.

I'd have three scoping rules for "car", "bus", and "train" to set a value, then 41 rule took in that scoped value and operated on it.

您仍然必须编写44条规则,但不必为每个范围确定案例重复41条规则.

You still have to write 44 rules, but you don't have to repeat the 41 for each scoping case.

这篇关于流口水中的嵌套规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆