[rules-users] null checking

Scott Reed sreed at avacoda.com
Fri Oct 17 09:56:32 EDT 2008


As I understand it, samd is asking how to test the cheese field (a collection, apparently) of seller for null. I think he just wants:

$s: seller: ( cheese != null && active == true )
cheese: ( type == "chedder" ) from $s.cheese

As Dave suggests, sam, it will help you a lot to spend some time looking over the manual and studying the tutorials.

vdelbart [10/17/2008 3:03 AM] wrote:
> I think it's not in the manual.
>
> Try this : 
>
> seller: ( seller.cheese != null, seller.active == true )
> cheese: ( this != null, cheese.type == "chedder" ) from seller.cheese
>
> I don't kown if it's fine but it works.
>
>
> dave sinclair wrote:
> > 
> > read the manual
> > 
> > http://downloads.jboss.com/drools/docs/4.0.7.19894.GA/html_single/index.html
> > 
> > On Thu, Oct 16, 2008 at 3:03 PM, samd <sdoyle_2 at yahoo.com> wrote:
> > 
> >>
> >>
> >>
> >> samd wrote:
> >> >
> >> > How do I evaluate null conditions in the following case for example?
> >> >
> >> > seller: ( seller.cheese != null && seller.active == true )
> >> > cheese: ( cheese.type == "chedder" ) from seller.cheese
> >> >
> >> > In the above example seller.cheese is null but seller is used in the
> >> > second part of the rule since we can't evaluate facts for null for some
> >> > reason how do you check for a null condition.
> >> >
> >> >
> >>
> >> should be cheese: ( type == "chedder" ) from seller.cheese
> >>
> >> anyways I tried doing this
> >>
> >> (
> >>  seller: ( seller.cheese != null && seller.active == true )
> >>  cheese: ( cheese.type == "chedder" ) from seller.cheese
> >> )
> >> or
> >> (
> >>  seller: ( seller.cheese = null && seller.active == true )
> >> )
> >> Which throws an error
> >> I just need the correct syntax I guess heh
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/null-checking-tp20015953p20016182.html
> >>  Sent from the drools - user mailing list archive at Nabble.com.
> >>
> >> _______________________________________________
> >> rules-users mailing list
> >> rules-users at lists.jboss.org
> >> https://lists.jboss.org/mailman/listinfo/rules-users
> >>
> > 
> > _______________________________________________
> > rules-users mailing list
> > rules-users at lists.jboss.org
> > https://lists.jboss.org/mailman/listinfo/rules-users
> > 
> > 
>
>   



More information about the rules-users mailing list