在下面的规则中,then-part中的逻辑是为所有通过给定条件的子对象执行的,我想在then-part中的逻辑只执行一次后中断循环,如何做到这一点
rule "test"
when
Parent( $childList : childList != null, childList.empty == false)
Child('testing'.equalsIgnoreCase(attribute)) from $childList
then
// testLogic
end
发布于 2018-08-06 22:42:33
如果不需要在RHS
中引用Child
对象(或其任何属性),则可以使用exists
运算符:
rule "test"
when
Parent( $childList : childList != null, childList.empty == false)
exists Child('testing'.equalsIgnoreCase(attribute)) from $childList
then
// testLogic
end
如果出于某种原因,您确实需要Child
对象或它的任何属性,您可以这样做(尽管这不是很好):
rule "test"
when
Parent( $childList : childList != null, childList.empty == false)
$c: Child('testing'.equalsIgnoreCase(attribute)) from $childList.get(0)
then
// testLogic
end
希望能有所帮助,
https://stackoverflow.com/questions/51709893
复制相似问题