Drools 将方法返回的值赋给句柄。
我有一个类似于下面的规则。我需要将匹配器返回的值分配给处理程序,以便在其他地方使用。我该怎么做?多谢各位Drools 将方法返回的值赋给句柄。,drools,Drools,我有一个类似于下面的规则。我需要将匹配器返回的值分配给处理程序,以便在其他地方使用。我该怎么做?多谢各位 package a.b.c import java.util.List; import a.b.Matcher; import a.b.Container; import a.b.TestObject1; import a.b.TestObject2; global Matcher myMatcher; global Container container; when
package a.b.c
import java.util.List;
import a.b.Matcher;
import a.b.Container;
import a.b.TestObject1;
import a.b.TestObject2;
global Matcher myMatcher;
global Container container;
when
$x1: TestObject1(
$x1_1 : id, (id in ("11", "16", "140"))
)
$x2: TestObject2(
$x2_2: id, myMatcher.match(id, container.getContainer(100)) != null
)
then
//print.
end
恐怕没有直接的方法可以做到这一点。 两个选择是:
rule 'Calculate match value'
$t: TestObject2()
when
TestObject2Match m = new TestObject2Match($t); // -> you must define this class
m.setMatchValue(myMatcher.match($t.getId(), container.getContainer(100)));
insertLogical(m);
then
rule '...'
$x1: TestObject1(
$x1_1 : id, (id in ("11", "16", "140"))
)
$m: TestObject2Match(matchValue != null)
when
//print $m.getMatchValue()
then
希望有帮助