<div dir="ltr">hi,<div>im new to drools..im trying to create a project as follows. i have a class called Monitor  which monitors a folder and creates two lists called fileOld( which is the list of filenames in that folder at time t1)  and fileNew(which is the list of filenames in that folder at time t2). i have another class called FileData which contains two members fileOld and fileNew (list of strings) with getters,setters and constructor. fileOld and fileNew from Monitor Class are passed to FileData class.</div>
<div><br></div><div>i also have another class called Event which is as follows:</div><div><div>public class Event {</div><div><span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">        </span> public static String name;</div>
<div><span class="" style="white-space:pre">        </span> private  File source;</div><div><span class="" style="white-space:pre">        </span> private  Date timeStamp;</div><div>        public  static  List&lt;Event&gt; listOfEvents = new ArrayList&lt;Event&gt;();</div>
<div><span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">        </span> </div><div><span class="" style="white-space:pre">        </span>public Event(String name, File source, Date timeStamp) {</div>
<div><span class="" style="white-space:pre">                </span><a href="http://this.name">this.name</a> = name;</div><div><span class="" style="white-space:pre">                </span>this.source = source;</div><div><span class="" style="white-space:pre">                </span>this.timeStamp = timeStamp;</div>
<div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">        </span></div><div><span class="" style="white-space:pre">        </span>public String getName() {</div>
<div><span class="" style="white-space:pre">                </span>return name;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>public void setName(String name) {</div>
<div><span class="" style="white-space:pre">                </span><a href="http://this.name">this.name</a> = name;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>public File getSource() {</div>
<div><span class="" style="white-space:pre">                </span>return source;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>public void setSource(File source) {</div>
<div><span class="" style="white-space:pre">                </span>this.source = source;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>public Date getTimeStamp() {</div>
<div><span class="" style="white-space:pre">                </span>return timeStamp;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span>public void setTimeStamp(Date timeStamp) {</div>
<div><span class="" style="white-space:pre">                </span>this.timeStamp = timeStamp;</div><div><span class="" style="white-space:pre">        </span>}</div><div><span class="" style="white-space:pre">        </span></div></div><div><br></div>
<div>now i have to compare these two lists(fileOld and fileNew) in a rule file and if they are not equal i have to create an event object for every file added and deleted and put it in the List&lt;Event&gt; listOfEvents.</div>
<div><br></div><div>here is my rule file:</div><div><br></div><div><div><span style="font-family:arial,sans-serif;font-size:13px">r</span><font face="arial, sans-serif">rule &quot;files are equal&quot;</font></div><div><span style="font-family:arial,sans-serif">    when </span></div>
<div><font face="arial, sans-serif">         FileData( fileOld == fileNew)</font></div><div><font face="arial, sans-serif">    then</font></div><div><font face="arial, sans-serif">       System.out.println(&quot;files are equal&quot;);</font></div>
<div><font face="arial, sans-serif">    </font><span style="font-family:arial,sans-serif">end</span></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif"><br></font></div><div><font face="arial, sans-serif">rule &quot;files not equal&quot;</font></div>
<div><font face="arial, sans-serif">when</font></div><div><font face="arial, sans-serif">    FileData($old : fileOld, $new : fileNew, fileOld != fileNew)</font></div><div><font face="arial, sans-serif">    </font></div><div>
<font face="arial, sans-serif">then</font></div><div><font face="arial, sans-serif">   accumulate( $s : String( this not memberOf $old ) from $new, $plus : collectList( $s ) ) </font></div><div><font face="arial, sans-serif">   accumulate( $t : String( this not memberOf $new ) from $old, $mins : collectList( $t ) ) </font></div>
<div><font face="arial, sans-serif">   System.out.println(&quot;files added:&quot; + $plus ); </font></div><div><font face="arial, sans-serif">   System.out.println( &quot;files deleted:&quot; + $mins );</font></div><div>
<font face="arial, sans-serif">end</font></div></div><div><br></div><div><br></div><div><br></div><div>how can i loop through each of the file added or deleted and create an Event Class object for every file added and deleted  and finally add all the created objects to List&lt;Event&gt; listOfEvents..</div>
<div><br></div><div><br></div><div>Thanks.</div></div>