Maybe I've just not found the documentation that explains how to deal with this.
I'm using Drools and want to compare to values in the same object as a condition for executing the RHS.
For example I might have:
public class Battery { private double charge; public void setCharge(double charge) { this.charge = charge; } public double getCharge() { return charge; } } public class DoubleA extends Battery { private double optimal; public double getOptimal(){ return optimal; } }
rule "DoubleA less than optimal" when b : DoubleA(charge < optimal); then b.chargeBattery(); end
One simple thing to do would be add a method to class that compares the fields and returns a boolean.
Otherwise, you can use the 'eval' - see documentation.
when
b : DoubleA( )
eval (getcharge() < getOptimal() )
then...