[rules-users] How to handle generics in Drools?

Wolfgang Laun wolfgang.laun at gmail.com
Mon Oct 17 05:37:13 EDT 2011


2011/10/17 Martin A <wmlsub at gmail.com>:
> Hello,
> In my rules file I'd like to set something like this:
> rule "mayThrowDice"
>     when
>         $user : User($gp : gameplay)
>         $gameplay(this == $gp)
>     then
>         exists List<Boost>() {
>             ..... some business logic
>         }

This looks weird: "exists" is a conditional element which can't be
used on the right hand side (after "then").


> end
> But it looks like there is no generics support

Correct.

>. How can I make sure there is
> a List of type Boost inserted into the session?

You would have to write some code that detects any element in the List
that is not instanceof Boost, or some accumulate that produces true if
all elements are instanceof Boost.

-W
> Thank you,
> Martin
> _______________________________________________
> 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