Mezoo Mezoo - 24 days ago 7
Java Question

ArrayList Grouping and Sum

How to from a list :

PojoA | child1 | aChildy | 1
PojoA | child3 | aChildz | 5
PojoA | child2 | aChildw | 4
PojoB | child4 | aChildw | 2
PojoB | child2 | aChildy | 3
PojoC | child2 | aChildz | 8


Grouping By child, aChild and sum last column ?

Java 8 grouping concatenation seems doesnt work. My POJOs is :

class Pojo{
UUID id;
Child child;
}

class Child{
UUID id;
AnotherChild aChild;
}


groupingBy(s -> s.getChild())
,
groupingBy(s -> s.getChild().getAnotherChild())
:
concat
grouping doesn't work. Why ?

Answer

Finally I did use classic loop for{ if..else }