[rules-users] Checking for a lack of an object

Chris Richmond crichmond at referentia.com
Fri Aug 19 11:13:44 EDT 2011


I forgot to mention I am using a StatefulKnowledgeSession and Stream mode...

On 8/19/2011 3:17 AM, Chris Richmond wrote:
> How do I fire a rule if an object with certain characterstics does not 
> exists.
>
> For example my class Foo, if I have a rule:
>
> rule "Identify Foos with values"
>
> when
>         Foo(stringProp=="blah", intProp==5)
> then
>         System.err.println("A Foo was found!");
> end
>
>
> So how do I check for lack of existence of an object with certain 
> characteristics
>
> I tried:
> rule "Flag missing Foos with values"
>
> when
>         not(Foo(stringProp=="blah", intProp==5))
> then
>         System.err.println("A proper foo does not exist");
> end
>
> I also tried:
> rule "Flag missing Foos with values"
>
> when
>         not(exists(Foo(stringProp=="blah", intProp==5)))
> then
>         System.err.println("A proper foo does not exist");
> end




More information about the rules-users mailing list