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;
  |   }
  | }

In my main function I set up all my pieces to get the rule base working with 
some instantiated objects.  Lets say for DoubleA #1, I say the charge is .68 
and the optimal value is .75.  For DoubleA #2, the charge is .72 and the 
optimal value is .70.

In my rule base, I want to monitor all my DoubleA batteries for when they are 
less than optimal.  It would make sense that I would write the rule somehow 
like this...

rule "DoubleA less than optimal"
  |   when
  |     b : DoubleA(charge < optimal);
  |   then
  |     b.chargeBattery();
  | end

However, this does not work.  I get an error message in Eclipse saying "Unable 
to return Declaration for identifier 'optimal'".  In haven't been able to find 
anything in the documentation about comparing the internal values of single 
objects, and the contraints on the RHS of the comparison operator only appears 
to work for literals or bound variables. I've tired many different permutations 
of making a bound variable out of 'optimal', but nothing seems to work, and I'm 
stumped.  There HAS to be a way to do this.  I can't imagine it was not thought 
of.

Any help appreciated!

Allen


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3961632#3961632

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3961632
_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to