I have a certain piece of code that looks pretty ugly, and I'm wondering if there is a prettier way of doing this.
This is what my normal "pretty" one line lambda's look like:
Boolean settingsChanged = key.pollEvents().stream()
.filter(e -> e.kind() == ENTRY_MODIFY) // Negate OVERFLOW
.anyMatch(e -> ((Path) e.context()).toAbsolutePath().equals(path));
But then I have this ugly line:
if (settingsChanged)
read().setHandler(arRead -> { if (arRead.succeeded()) handler.handle(arRead.result()); });
I tried writing this as follows:
read().setHandler(arRead -> if (arRead.succeeded()) handler.handle(arRead.result()));
But the compiler doesn't like this. Is there any way to pretty the code up?