开发者

drools rules syntax for nested classes

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜