문제

I want to know how can I express one object is null on the left hand side when I use drools rule engine? And anybody can tell me how to use the drools keyword "not" and so on.Thank you!

도움이 되었습니까?

해결책

You can call not in when clause to check for null objects:

rule "somerule"
    no-loop
    when not AnObject()
    then
      // rule body when AnObject is null
end;

다른 팁

Drools is built on top of Java, so there is an instance of the object (which may or may not have null properties) or there is not. If the object is a 'fact' in working memory, then it is not null and your LHS should instead be determining whether it exists:

exists MyObject()
not exists MyObject()

However if you are trying to find facts with null properties, you can do this:

obj: MyObject(myProperty == null)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top