Intersecting List with keys of Map
You can stream set of entries:
map.entrySet().stream()
.filter(e -> list.contains(e.getKey()))
.collect(toMap(Map.Entry::getKey, Map.Entry::getValue));
If you also want to map keys to id
field, then:
map.entrySet().stream()
.filter(e -> list.contains(e.getKey()))
.collect(toMap(e -> e.getKey().getId(), Map.Entry::getValue));