I have the following rule:
when
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client : FixedClient(lastChargeDate > 3)
then
...
From the logs it seems that even if the first condition returns true (i.e. service is null) the rest of the conditions are still evaluated which results in a null pointer exception. Is there a way to optimise the conditions so the evaluation stops when a false condition is met (similarly to how && works in Java)?
What this condition:
not FixedClient(service == null) and
not FixedClient(service.statusCode == "CU") and
$client: FixedClient(lastChargeDate > 3)
means is: "If there is no client with service equal to null and if there is no client with status code equal to "CU" and if there is (one or more) clients with last charge date greater than three, then execute..."
The operator not
in front of a pattern is the negative existence quantifier, in (logic) denoted by ∄
. This must not be confused with the logic operator not
denoted in logic by ¬
or, in Java: !
. In everyday parlance, this is expressed by saying that there is, for instance, "no red car" as opposed to stating that "there is a car with colour not equal to red".
Modify your condition like this:
when
$client: FixedClient(service != null &&
service.statusCode != "CU",
lastChargeDate > 3)
then
to find a client with service to some value that is neither null nor CU and a last charge date greater than 3.