[rules-users] Class test fails (!= same as ==)

Wolfgang Laun wolfgang.laun at gmail.com
Mon Mar 12 09:20:50 EDT 2012


Using 5.3.0.Final, arbitrary facts and the rule shown below:

import org.drools.reteoo.InitialFactImpl

rule "Clear" when
    $f: Object()  #######
then
    if( ! ($f instanceof InitialFactImpl) ){
      System.out.println( "retract a " + $f.getClass() );
      retract( $f );
    }
end

This retracts my Foo, Bar and Counter facts. Good.

    $f: Object( class == Foo.class )  ####### changed

This retracts all of my Foo facts. Excellent.

    $f: Object( class != Foo.class )  ####### changed again

This retracts only Foo facts. Bad.

-W



More information about the rules-users mailing list