Java 8 Lambda Stream forEach with multiple statements
I am still in the process of learning Lambda, please excuse me If I am doing something wrong
final Long tempId = 12345L;
List<Entry> updatedEntries = new LinkedList<>();
for (Entry entry : entryList) {
entry.setTempId(tempId);
updatedEntries.add(entityManager.update(entry, entry.getId()));
}
//entryList.stream().forEach(entry -> entry.setTempId(tempId));
Seems like can be executed for one statement only. It doesn't return updated stream or function to process further. I might have selected wrong one altogether.forEach
Can someone guide me how to do this effectively?
One more question,
public void doSomething() throws Exception {
for(Entry entry: entryList){
if(entry.getA() == null){
printA() throws Exception;
}
if(entry.getB() == null){
printB() throws Exception;
}
if(entry.getC() == null){
printC() throws Exception;
}
}
}
//entryList.stream().filter(entry -> entry.getA() == null).forEach(entry -> printA()); something like this?
How do I convert this to Lambda expression?