<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Arial, sans-serif" size="3">
<div>&nbsp;</div>
<div><font size="2">I'm going through the Drools documentation regarding the use of lists and other collections. I want to make sure my understanding is correct.</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">So if I have a class:</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font face="Courier New, monospace" size="2">public class Foo {</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; private int x;</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; private int y;</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; private List&lt;String&gt; names = ArrayList&lt;String&gt;();</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; public List&lt;String&gt; getNames() {return names;}</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; // appropriate getters/setters for the int fields ...</font></div>
<div><font face="Courier New, monospace" size="2">}</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;</font></div>
<div><font size="2">With this I can insert a Foo object into working memory. I can even make the int fields dynamic facts with the appropriate addition of &quot;bean-ifying&quot; code.</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">For the List, however, I need to insert it separately into working memory in order to make use of Drools' rule language ('contains' ,etc.)? I'm assuming that doesn't come free because I have to insert my own custom class objects if they
are included via composition in a larger fact!</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">Also, I'm guessing the Collection type classes cannot be dynamic facts? Meaning if I modify my List with add, remove,&nbsp; clear, etc., I must explicitly call update in my code on the List fact in order to alert Drools to a change in the List,
correct? </font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">So then the question also comes up as to how I would write a rule that looks for all instances of Strings in the List that match against a given regex expression. I've not been successful at figuring this out...</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font face="Courier New, monospace" size="2">Rule &quot;when a Foo List is modified, get all Strings in it that start with 'error'&quot;</font></div>
<div><font face="Courier New, monospace" size="2">when</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; $foo : Foo($names : names)</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; $foundThese : ArrayList() from collect(??? matches &quot;error.*&quot; from $names)</font></div>
<div><font face="Courier New, monospace" size="2">then</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;&nbsp; // act on $foo and $foundThese</font></div>
<div><font face="Courier New, monospace" size="2">&nbsp;</font></div>
<div><font size="2">I know that rule is NOT correct, but I'm not sure how I'm supposed to access an immutable object inside a collection. The examples in the documentation show how to get at mutable class objects.</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">Thanks!</font></div>
<div><font size="2">-Allen</font></div>
<div style="margin-top: 5pt; margin-bottom: 5pt; "><font size="2">&nbsp;</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">&nbsp;</font></div>
<div><font size="2">&nbsp;</font></div>
</font>
</body>
</html>