Given the code:
Optional<String> myOptional = getMyOptional();
myOptional.ifPresentOrElse(
s -> Optional.ofNullable(someMap.get(s))
.ifPresentOrElse(g -> {
doSomeStuff();
},
() -> doErrHandling()),
() -> doErrHandling());
Now I am thinking about how to simplify the chain and remove the duplicate code line (() -> doErrHandling()
).