I've recently reviewed code twice, from two different authors, where the author has cleverly used Thingy z = Optional.ofNullable(x).orElse(y) rather than using, say, Thingy z = x == null ? y : x.
My first reaction was that this is not the intended use or semantic of Optional and that a ternary conditional operator, or even just an if-else, would be better.
But the more I look at it, there is a beauty and a fluidity to Thingy z = Optional.ofNullable(x).orElse(y) which makes sense. To be honest, I've actually never loved the conditional operator.
Thoughts?