[rules-users] Can't check if an attribute is member of an object of class class com.sample.WorkDays

Edson Tirelli tirelli at post.com
Fri Oct 3 09:21:58 EDT 2008


   You can only use memberOf with Collection or arrays, so you should be
binding your variables to the list, instead of the class:

Workdays( $wd : workDays )

   []s
   Edson

2008/10/3 Marcin Krol <mrkafk at gmail.com>

>
> I'm doing this:
>
> ThermostatTimeData ttd1 = new ThermostatTimeData("January", "Monday", 14);
> session.insert(ttd1);
> WorkDays wd = new WorkDays();
> session.insert(wd);
> session.fireAllRules();
> printoutThermostatData(ttd1);
>
> and then this:
>
> rule "Rule 1"
>  when
>    $wd : com.sample.WorkDays()
>    $ttd : ThermostatTimeData ( day memberOf $wd )
>  then
>        modify ( $ttd ) {
>         setDaytype("workday")
>        }
>        System.out.println("Rule 1 fired.");
> end
>
> And I get the error like in subject. Anybody knows why?
>
>
> WorkDays.java:
>
> package com.sample;
> import java.util.ArrayList;
> import java.util.List;
>
>
> public class WorkDays {
>                private List<String> wd;
>
>                public WorkDays() {
>                        this.wd = new ArrayList<String>();
>                        this.wd.add("Monday");
>                        this.wd.add("Tuesday");
>                        this.wd.add("Wednesday");
>                        this.wd.add("Thursday");
>                        this.wd.add("Friday");
>                }
>
>                public List<String> getWorkDays() {
>                        return this.wd;
>                }
> }
>
>
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



-- 
 Edson Tirelli
 JBoss Drools Core Development
 JBoss, a division of Red Hat @ www.jboss.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20081003/006d9d17/attachment.html 


More information about the rules-users mailing list