I have List<Model>:
[
{parent: "parent", child: "child1", sensor: "wohoo"},
{parent: "parent", child: "child1", sensor: "bla"},
{parent: "parent", child: "child2", sensor: "wohoo2"}
]
and I want to convert it to a map <String, Map<String, List<String>>>.
{
parent: {
child1: ["wohoo", "bla"],
child2: ["wohoo2"]
},
}
I tried this:
Map<String, Map<String, List<String>>> test = currentlyReportingAgents
.stream()
.collect(Collectors.groupingBy(
Model::getParent,
Collectors.groupingBy(Model::getChild, Collectors.toList())));
but got some errors in wired compilation. What am I missing?
Edit: Added screenshot of the error:

source
share