title: Filter and collect a Map<String, List<Object>> to Map<String, List<Object>> based on a condition
body: <p>Let</p>
  <pre><code>class Person {
      String name;
      int age;
  }
  </code></pre>
  <p>My variable is</p>
  <pre><code>Map&lt;Sring, List&lt;Person&gt;&gt; myVariable;
  </code></pre>
  <p>The result I'm aiming to get is</p>
  <pre><code>Map&lt;String, List&lt;Person&gt;&gt; result;
  </code></pre>
  <p>The condition is to collect all persons satisfying this condition</p>
  <pre><code>Predicate&lt;Person&gt; predicate = p -&gt; p.age &gt; 20;
  </code></pre>
  <p>If an entry in the map contains 3 persons and only 2 of them satisfies this condition, the 3rd one should be removed</p>
  <p>Example: myVariable =</p>
  <pre><code>&quot;1&quot;: [{name: &quot;Foo&quot;, age: 15}, {name: &quot;Foo&quot;, age: 13}, {name: &quot;Foo&quot;, age: 14}]
  &quot;2&quot;: [{name: &quot;Foo&quot;, age: 15}, {name: &quot;Foo&quot;, age: 13}, {name: &quot;Foo&quot;, age: 14}]
  &quot;3&quot;: [{name: &quot;Foo&quot;, age: 15}, {name: &quot;Foo&quot;, age: 13}, {name: &quot;Foo&quot;, age: 14}]
  &quot;4&quot;: [{name: &quot;Foo&quot;, age: 15}, {name: &quot;Foo&quot;, age: 21}, {name: &quot;Foo&quot;, age: 27}]
  </code></pre>
  <p>result =</p>
  <pre><code>&quot;4&quot;: {name: &quot;Foo&quot;, age: 21}, {name: &quot;Foo&quot;, age: 27}]
  </code></pre>
  <p>I tried this</p>
  <pre><code>Map&lt;String, List&lt;Persin&gt;&gt; result = myVariable.keySet().stream()
              .filter(p -&gt; myVariable.keySet(p).stream().anyMatch(predicate))
              .collect(Collectors.toMap(p -&gt; p, myVariable.get(Function.identity()).stream().filter(predicate).collect(Collectors.toList())));
  </code></pre>
  <p>But it doesn't work.</p>