title: Partitioning a Map in Java 8+
body: <p>I have a <code>Map&lt;String, String&gt;</code> and a <code>List&lt;String&gt;</code>. I'd like to partition the <code>Map</code> based on the condition </p>
  
  <pre><code>foreach(map.key -&gt; list.contains(map.key))
  </code></pre>
  
  <p>and produce two <code>Map</code>(s). What's the most elegant way to do so? I'm on Java 11, so you can throw everything you want in the answers.</p>
  
  <p>What I came up to for now is:</p>
  
  <pre><code>map.entrySet()
     .stream()
     .collect(partitioningBy(e -&gt; list.contains(o.getKey())));
  </code></pre>
  
  <p>but that gives a <code>Map&lt;Boolean, List&lt;Entry&lt;String, String&gt;&gt;&gt;</code>.</p>