如果其中一个条件不匹配,DROOLS 停止评估
DROOLS Stop Evaluation if one of the conditions doesn't match
我有以下规则:
when
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client : FixedClient(lastChargeDate > 3)
then
...
从日志看来,即使第一个条件 returns 为真(即服务为空),仍会评估其余条件,这会导致空指针异常。有没有一种方法可以优化条件,以便在满足错误条件时停止评估(类似于 && 在 Java 中的工作方式)?
什么条件:
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client: FixedClient(lastChargeDate > 3)
意思是:"If there is no client with service equal to null and if there is no client with status code equal to "CU”并且如果有(一个或多个)客户的最后收费日期大于三个,则执行...”
模式前面的运算符not
是负存在量词,在(逻辑)中用∄
表示。这不能与逻辑运算符 not
混淆,在逻辑中用 ¬
表示,或者在 Java 中表示:!
。在日常用语中,这表示为存在,例如 "no red car",而不是 "there is a car with colour not equal to red".
像这样修改你的条件:
when
$client: FixedClient(service != null &&
service.statusCode != "CU",
lastChargeDate > 3)
then
查找某个值既非空也非 CU 且上次收费日期大于 3 的客户。
我有以下规则:
when
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client : FixedClient(lastChargeDate > 3)
then
...
从日志看来,即使第一个条件 returns 为真(即服务为空),仍会评估其余条件,这会导致空指针异常。有没有一种方法可以优化条件,以便在满足错误条件时停止评估(类似于 && 在 Java 中的工作方式)?
什么条件:
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client: FixedClient(lastChargeDate > 3)
意思是:"If there is no client with service equal to null and if there is no client with status code equal to "CU”并且如果有(一个或多个)客户的最后收费日期大于三个,则执行...”
模式前面的运算符not
是负存在量词,在(逻辑)中用∄
表示。这不能与逻辑运算符 not
混淆,在逻辑中用 ¬
表示,或者在 Java 中表示:!
。在日常用语中,这表示为存在,例如 "no red car",而不是 "there is a car with colour not equal to red".
像这样修改你的条件:
when
$client: FixedClient(service != null &&
service.statusCode != "CU",
lastChargeDate > 3)
then
查找某个值既非空也非 CU 且上次收费日期大于 3 的客户。