title: Java filter map inside List<Object>
body: <p>I've run in to bit of a problem here and can't seem to find a solution.</p>
  
  <p>I've got a list of objects that contain a Map of String, Object2.
  Object 2 itself contains a Map of String, String</p>
  
  <p>How do I sort this to end up with a List with Map String, Object2 only containing entries where Map String, String is not empty?</p>
  
  <p>This is what I got so far:</p>
  
  <pre><code> list.stream()
              .filter(i -&gt; i.getServices().entrySet().stream()
                      .filter(c -&gt; c.getValue() != null))
              .collect(Collectors.toList());
  </code></pre>
  
  <p>However that results in the following error:</p>
  
  <pre><code>Type mismatch: cannot convert from Stream&lt;Map.Entry&lt;String,Object&gt;&gt; to boolean
  </code></pre>
  
  <p>I've been banging my head against this all morning. If someone could help me out here I would be very grateful. Thanks in advance!</p>
  
  <p>With flatmap I end up with the required lists of map but lose the superclass, like so:</p>
  
  <pre><code>         List&lt;Entry&lt;String, Service&gt;&gt; a = list.stream()
           .flatMap(cus -&gt; cus.getServices().entrySet().stream())
           .filter(service -&gt; service.getValue() != null)
           .collect(Collectors.toList());
  </code></pre>
  
  <p>Edit: for clarifications:
  1st object:</p>
  
  <pre><code>public class Subscription {
      ...
      public Map &lt;String, Service&gt; services;
  }
  </code></pre>
  
  <p>2nd object:</p>
  
  <pre><code>public class Service {
  
  ...
  private Map&lt;String, String&gt; params;
  
  }
  </code></pre>
  
  <p>"params" is what needs to be filtered.</p>