我正在使用 Optaplanner 6.2Final 版本,除了匹配运算符外,一切正常。为了解释更多,这是我的规则。
rule "TEST REG EXP OPERATOR"
when
$cheese:Cheese($cheese.type matches "(Buffulo)?\\S*Mozarella")
then
scoreHolder.addSoftConstraintMatch(kcontext, 1);
end
以下是抛出的异常:
Exception in thread "main" [Error: unable to resolve method: com.app.test.domain.Cheese.$cheese() [arglength=0]]
[Near : {... $cheese.type ~= "(Buffulo)?\\S*Mozarella" ....}]
注意:如果我删除了 $cheese. 在type前面声明,规则没有问题。这工作正常:
$cheese:Cheese($cheese.type == "Buffulo")
任何建议,将不胜感激。
更新: 事实证明,在我检查完所有版本后,以下仅在 drools 核心版本 6.2.0.Final 和 6.3.0.Final 上引发异常。它适用于其余版本。
$cheese:Cheese($cheese.type matches "(Buffulo)?\\S*Mozarella")