¿Cómo iterar listas anidadas con flujos lambda?
Estoy tratando de refactorizar el siguiente código para expresiones lambda con `stream, especialmente los bucles foreach anidados:
public static Result match (Response rsp) {
Exception lastex = null;
for (FirstNode firstNode : rsp.getFirstNodes()) {
for (SndNode sndNode : firstNode.getSndNodes()) {
try {
if (sndNode.isValid())
return parse(sndNode); //return the first match, retry if fails with ParseException
} catch (ParseException e) {
lastex = e;
}
}
}
//throw the exception if all elements failed
if (lastex != null) {
throw lastex;
}
return null;
}
Estoy empezando con:
rsp.getFirstNodes().forEach().?? // how to iterate the nested 2ndNodes?