I have a Group object that looks like this
public class Group {
private String mName;
private List<Item> mItems;
}
and an Item object that looks like this
public class Item {
private String mNumber;
}
Now let's say I have a first list like List<Group> { ["Group1", {Item1, Item2, Item3}] } and a second one like List<Group> { ["Group1", {Item2}] }.
I would like to remove Item2 from the first list with lambda.
What I have so far is the following but I'm stuck in the middle.
firstList.stream()
.flatMap(group -> group.getItemList().stream())
.filter(item -> (
// here I'm stuck. I think i need a stream of the second list or something?
))
.collect(Collectors.toList());
The result should look like List<Group> {["Group1", {Item1, Item3}]}
List(firstList) or create a new outputList?