I'm going through the Drools documentation regarding the use of lists and other collections. I want to make sure my understanding is correct.
 
So if I have a class:
 
public class Foo {
 
   private int x;
   private int y;
   private List<String> names = ArrayList<String>();
 
   public List<String> getNames() {return names;}
 
   // appropriate getters/setters for the int fields ...
}
 
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 "bean-ifying" code.
 
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!
 
Also, I'm guessing the Collection type classes cannot be dynamic facts? Meaning if I modify my List with add, remove,  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?
 
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...
 
Rule "when a Foo List is modified, get all Strings in it that start with 'error'"
when
   $foo : Foo($names : names)
   $foundThese : ArrayList() from collect(??? matches "error.*" from $names)
then
   // act on $foo and $foundThese
 
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.
 
 
Thanks!
-Allen