我正在尝试为我正在处理的一个java项目编写一个Drools文件,并且我的一条规则严重依赖于小于或等于。我在一些地方读到过,你不应该使用<
,实际上应该使用<
。这可能意味着<=
将成为<=
Netbeans也用红色突出显示了我的<
,这表明有些地方不对劲。
在我看来,这完全是疯了--这是否意味着下面的代码会发生如下变化:
($T1.getValue()<$T2getValue)&&($T1.getOtherValue()<=$T2getOtherValue)
变成了
($T1.getValue()<$T2getValue)&&($T1.getOtherValue()<=$T2getOtherValue)
对此有何解释?
发布于 2014-04-15 14:08:03
在*.drl
文件中,您可以安全地使用<
和>
。它不需要XML或HTML转义。
例如,请注意其中一个optaplanner示例中的规则中的>:
rule "requiredCpuPowerTotal"
when
$computer : CloudComputer($cpuPower : cpuPower)
$requiredCpuPowerTotal : Number(intValue > $cpuPower) from accumulate(
CloudProcess(
computer == $computer,
$requiredCpuPower : requiredCpuPower),
sum($requiredCpuPower)
)
then
scoreHolder.addHardConstraintMatch(kcontext, $cpuPower - $requiredCpuPowerTotal.intValue());
end
我会把你的代码写成这样:
T1($t1Value : value, $t1OtherValue : otherValue)
T2(value < $t1Value, otherValue <= $t1OtherValue)
https://stackoverflow.com/questions/23076615
复制相似问题