title: DROOLS pattern matching nested lists with complex objects
body: <p>I'm struggling with a pattern-matching routine in DROOLs that traverses lists of complex nested objects.</p>
  
  <p>I have a POJO structure something like this:</p>
  
  <pre><code>class MyFact {
      private List&lt;A&gt; listOfA;
      public List&lt;A&gt; getListOfA() { return listOfA; }
  }
  
  class A {
      private List&lt;B&gt; listOfB;
      private String stringField;
      public List&lt;B&gt; getListOfB() { return listOfB; }
      public String getStringField() { return stringField; }
  }
  
  class B {
      private String otherStringField;
      public String getOtherStringField() { return otherStringField; }
  }
  </code></pre>
  
  <p>I am trying to find the correct syntax to collect all objects of type 'A' that match a set of criteria that also includes matching fields in objects contained within 'A's <code>listOfB</code>.</p>
  
  <p>I think the rule needs to look something like this, but the pattern I have won't compile while it is inside the <code>collect( ... )</code></p>
  
  <pre><code>import java.util.ArrayList;
  rule "Tricky Syntax"
  when
      $myFact: MyFact()
      $filteredListOfA: ArrayList( size &gt; 0 ) from collect ( 
          A( stringField == "something", $listOfB: listOfB ) from $myFact.listOfA
          B( otherStringField == "somethingElse" ) from $listOfB
      ) 
  then
     // Do something neat with $filteredListOfA
  end
  </code></pre>
  
  <p>I know it could be written in such a way where each element is matched iteratively but I only want to fire the action once and have a single List of A if there are any matches.
  Thanks!</p>