I have the following problem: Given these classes,
class Person { private String zip; ... public String getZip(){ return zip; } } class
I suspect the cleanest way to do this -- I'm not quite happy with the other answers posted -- would be
persons.stream().collect(Collectors.toMap( person -> person, person -> regions.stream() .filter(region -> region.getZipCodes().contains(person.getZip())) .collect(Collectors.toList())));