I have a Map<String, String>
and a List<String>
. I'd like to partition the Map
based on the condition
foreach(map.key -> list.contains(map.key))
and produce two Map
(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.
What I came up to for now is:
map.entrySet()
.stream()
.collect(partitioningBy(e -> list.contains(o.getKey())));
but that gives a Map<Boolean, List<Entry<String, String>>>
.