Lets say I have this class:
public class Employee{
private int id;
private List<Car> cars;
//getters , equals and hashcode by id
}
public class Car {
private String name;
}
I have a List of Employees (same id may be duplicated):
List<Employee> emps = ..
Map<Employee, List<List<Car>>> resultMap = emps.stream().collect(
Collectors.groupingBy(Function.identity(),
Collectors.mapping(Employee::getCars, Collectors.toList());
This gives me Map<Employee, List<List<Car>>>,
how can I get a Map<Employee, List<Car> (like a flat List)?