I have the following problem: Given these classes,
class Person {
private String zip;
...
public String getZip(){
return zip;
}
}
class
I have not done any testing of this code, but it compiles so it must be right (:eyeroll:).
public Map> mapPeopleToRegion(List people, List regions){
final Map> personToRegion = new HashMap<>();
people.forEach(person ->
personToRegion.put(
person,regions.stream().filter(
region -> region.getZipCodes().contains(person.getZip()))
.collect(Collectors.toList())));
return personToRegion;
}