Have you looked at eval()?

From: [email protected] 
[mailto:[email protected]] On Behalf Of tom ska
Sent: 06 August 2010 10:49
To: [email protected]
Subject: [rules-users] Math calculations on attributes in WHEN section of rules.

Hello,
what I want to do, is to calculate on object's attributes in WHEN section of 
rule. Can I do it?

For example:

class CObj
{
              private int k;
              private int n;

              // setters and getters
}

Now what I want to do is:

rule "r1"
    when
        p : CObj ( k + n <= 1000)
    then
        System.out.println("We love Drools :)");
end

Why can't I construct conditions like in Java, or C++ (with calculations in 
conditions)? How can I achieve my goal?

Thx,
Tom.

________________________________

**************************************************************************************
This message is confidential and intended only for the addressee. If you have 
received this message in error, please immediately notify the 
[email protected] and delete it from your system as well as any copies. The 
content of e-mails as well as traffic data may be monitored by NDS for 
employment and security purposes. To protect the environment please do not 
print this e-mail unless necessary.

NDS Limited. Registered Office: One London Road, Staines, Middlesex, TW18 4EX, 
United Kingdom. A company registered in England and Wales. Registered no. 
3080780. VAT no. GB 603 8808 40-00
**************************************************************************************
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to