In java, I can check to see if a 2 variables references the same instance as such:

Object a = new Object();
Object b = a;

a == b




Is there a way to do this in Drools? For instance, if there is an object in working memory and it is a specific instance, I do not want to fire the rule again. ie:

rule "User Lookup UserKey"
    salience 10000
    when
        com.kronos.taws.model.User(empId == null, $key:empIdKey)
    then
        System.out.println("Firing 2!");
        insert($key);

end

I want to ensure that $key is not already in working memory. But mind you, there might be other $keys that are in working memory that do not belong to this particular com.kronos.taws.model.User instance. I do not want this rule to fire because I have subsequent rules that will make empId a value other than null.

I attempted to do this:

rule "User Lookup UserKey"
        when
                com.kronos.taws.model.User(empId == null, $key:empIdKey)
                not UserKey(this == $key)
        then
                System.out.println("Firing 2!");
                insert($key);
                
end

However, I still think this is doing an equality check because once the $key object is updated in another rule, this rule is fired again!

Thanks in advance!
Eric

_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to