I am trying to stream-ify the following logic:
I have a map of Integer ids to an integer count. I have a list of Pojos that represent the ids. I want to merge the two and have a map of pojos to integer count.
Currently I have:
return EntryStream.of(idToCountMapping)
.mapKeys(k -> StreamEx.of(pojos).findFirst(s -> s.getId().equals(k)))
.filterKeys(Optional::isPresent)
.mapKeys(Optional::get)
.mapKeyValue(SuperCoolNewPojo::new)
.toList();
The first mapKeys()
call strikes me as something that is probably much better expressed in a different way.
Any help would be great!
Thanks, Anthony