7

I am trying to write a rule in drools drl language where I am want to do something like !(A && B) but it doesnt seem to like the ! operator or the word not. I am struggling to find good documentation on drools

Please see sample code below:

  rule "Test Rule"
   when
      testBean : testBean(!(testList contains "test"  && testList2 contains "test2"))
   then
      testBean.setText( "This is a test" );
   end

I would appreciate any help than anyone can give me

thanks in advance

Burt Beckwith
  • 75,342
  • 5
  • 143
  • 156
mh377
  • 1,656
  • 5
  • 22
  • 41

2 Answers2

4

It looks like there is an open defect with the not operator

https://jira.jboss.org/browse/JBRULES-2404

Another good article on negation, uses 'neg' or 'naf' instead of 'not'

http://blog.athico.com/search?q=negation

rule "Test Rule"
   when
      testBean : testBean((testList not contains "test"  && testList2 contains "test2"))
   then
      testBean.setText( "This is a test" );
   end
mh377
  • 1,656
  • 5
  • 22
  • 41
0

For me, I use ==false syntax

testBean : testBean(false==(testList contains "test"  && testList2 contains "test2"))
einverne
  • 6,454
  • 6
  • 45
  • 91