访问LHS

时间:2016-12-26 15:06:07

标签: drools drools-fusion

我定义了一个带有静态字段的类,我想访问规则左侧的字段。有可能吗?

这是班级:

package cep.model;

public class Events {
    public static final int A = 1;
    public static final int B = 2;
    public static int getA() {
        return A;
    }

    public static int getB() {
        return B;
    }
}

和规则:

package cep.drl;
dialect  "mvel"
import cep.Event;
import cep.model.Events;

declare Event
@role(event)
@expires( 20s )
end

//A & B
rule "r001"
no-loop
    when
    $a : Event(typeId == Events.A)
    and $b : Event(typeId == Events.B)
    then
end

使用drools插件编译后:

Unable to Analyse Expression typeId == Events.A:
[Error: unable to resolve method using strict-mode: cep$Event.Events()]
[Near : {... typeId == Events.A ....}]
                       ^
[Line: 15, Column: 4] : [Rule name='r001']


Unable to Analyse Expression typeId == Events.B:
[Error: unable to resolve method using strict-mode: cep$Event.Events()]
[Near : {... typeId == Events.B ....}]
                       ^
[Line: 16, Column: 8] : [Rule name='r001']

1 个答案:

答案 0 :(得分:0)

我认为你必须以这种方式放置规则,replace == to:绑定到Events.A

rule "r001"
no-loop
    when
    $a : Event(typeId : Events.A)
    and $b : Event(typeId == Events.B)
    then
end
相关问题