title: filter inner and outer list in java using streams
body: <p>Is there a way to filter both inner and outer lists using some predicate and java streams? For example:</p>
  
  <pre><code>Class outerObject{
      int num;
      List&lt;innerObject&gt; innerObjectList;
  }
  Class innerObject{
      int num;
  }
  List &lt;outerObject&gt; outerObjectList
  </code></pre>
  
  <p>Is there a way to filter the list such that the <code>outerObject</code> list has field <code>num = 10</code> and the list of <code>innerObject</code>'s for the corresponding <code>outerObject</code> is also filtered by corresponding field <code>num = 10</code>?</p>
  
  <p>I tried:</p>
  
  <pre><code>outerObjectList.stream()
                 .filter(i -&gt; i.getNum() == 10)
                 .filter(i -&gt; i.getOrders().stream().anyMatch(s -&gt; getNum() == 10))
                 .collect(Collectors.toList());
  </code></pre>
  
  <p>But it does not seem to filter the inner list. </p>
  
  <p>Descriptive example:</p>
  
  <p>If a outer list has 3 objects with <code>num = 10</code> and each of the 3 object has 1 inner object in their <code>innerObjectList</code> with <code>num = 10</code> then it should give me a list of 3 <code>outerObject</code> with a list of 1 <code>innerObject</code> each.</p>