Is it possible to transform List<Entry>
to Map<Employee, Map<LocalDate, Entry>>
with one lambda expression?
public class Entry {
Employee employee;
LocalDate date;
}
So far i have came up with something like this:
entries.stream().collect(Collectors.toMap(Collectors.groupingBy(Entry::getEmployee), Collectors.groupingBy(Entry::getDate), Function.identity()));
But this gives a compilation error:
no suitable method found for
toMap(java.util.stream.Collector<com.a.Entry,capture#1 of ?,java.util.Map<com.a.Employee,
java.util.List<com.a.Entry>>>,java.util.stream.Collector<com.a.Entry,capture#2 of ?,
java.util.Map<java.time.LocalDate,java.util.List<com.a.Entry>>>,
java.util.function.Function<java.lang.Object,java.lang.Object>)
Thanks