I have an Integer, and I want to compare it to some raw int like so:
$day : Day()
$itemsList : from collect(Item())
$number : Integer() from $day.getNumberOfItemsAvailable($itemsList)
$number > 4
but I'm getting
Message [id=1, kieBase=defaultKieBase, level=ERROR, path=ScoreRules.drl, line=42, column=0
text=[ERR 102] Line 42:21 mismatched input '<' in rule "rule"]
How do you compare an Integer to some other int value? Could you point me to some documentation that explains basics like this?
While you could use an eval statement as suggested in the previous answer, such constructs are not recommended because they can't be optimized.
Alternatively you could check in the same line where you assign your $number
variable like this:
$number : Integer( this > 4 ) from $day.getNumberOfItemsAvailable($itemsList)
This will only assign number if the getNumberOfItems...
call returns an integer greater than four. If the returned value is less, the condition won't be satisfied and the rule won't be evaluated.