I have a nested list to loop through in pre Java 8. My example is very similar to loop through nested list in java 8 which is a great example to follow then I realized that I need to check for null for each list. Plz refer to the below example. If the last condition is met then return true by short-circuiting.
However I am not sure how to check null for each list using list.stream().flatMap().
for(A a : ListA) {
if(a.getListB() != null && !a.getListB().isEmpty()) {
for(B b : a.getListB()) {
if(b.getListC() != null && !p.getListC().isEmpty()) {
for(C c : b.getListC()) {
return (c.name.equalsIgnoreCase("john"));
}
}
}
}
}