0

我正在尝试为我正在处理的 java 项目编写 Drools 文件,而我的规则之一严重依赖于小于或等于。我已经阅读了几个你不应该使用<并且实际上应该使用的地方&lt;。大概这意味着<=会变成&lt;=?

Netbeans<也用红色突出显示我的,这表明有问题。

这对我来说似乎完全疯了 - 这是否意味着下面的代码更改如下:

($T1.getValue()<$T2getValue)&&($T1.getOtherValue()<=$T2getOtherValue)

变成

($T1.getValue()&lt;$T2getValue)&&($T1.getOtherValue()&lt;=$T2getOtherValue)

对此有何解释?

4

1 回答 1

1

*.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)
于 2014-04-15T14:08:03.287 回答