Consider a Parent
class with the attributes attrib1
, attrib2
and List
child with its corresponding getters and s
As I can understand you should add additional filter for child lists:
parent.stream().filter(e -> e.getChild().stream().anyMatch(c -> c.getAttrib1() > 10)).forEach(e -> e.setChild(e.getChild().stream().filter(c -> c.getAttrib1 > 10).collect(toList())))
If you have not setChild:
To remove you can use iterator:
parent.stream().filter(e -> e.getChild().stream().anyMatch(c -> c.getAttrib1 > 10))
.forEach(e -> {
for(Iterator it = e.getChild().iterator(); it.hasNext();){
Child cur = it.next();
if(cur.getAttrib1() <= 10) it.remove();
}
})