开发者

drools rules syntax for nested classes

开发者 https://www.devze.com 2023-02-22 13:08 出处:网络
Newbie question on drools. I am trying to access the following java class in the rules file. Class A{

Newbie question on drools. I am trying to access the following java class in the rules file.

Class A{
  private String foo;
  private SomeClass B;
  //getter setter for foo and b
}
Class B{
  private String bar;
  private Integer value;
  //getter setter for bar and value
}

In the rule file I would like to access the member bar.

So far this is what I have:-

package demo;
import my.test.A;
import my.test.B;

rule "Rule1"
    when
        $varB : A.B(bar.equals("hello")) 
    then 
        $varB.setValue(1);
        update($varB);
end

For the above rule I get this error - "BuildError: Unable to resolve ObjectType A.B". I also tried using A.getB() and that did not help either. Any idea what it should be? I am using eclipse drools plugin if that matters.

I have looked at the jboss rules docs but they do not cover the syntax stuff that well. Does anyone know of links where I can look up drools sy开发者_Go百科ntax and how tos like above?


This is probably better:

A(b.bar == "hello", $varB : b) 

In DRL, == means equals, not same. With $varB : b you do something like B varB = a.getB();


try this way:

$varB : A(B.bar.equals("hello")) 
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号