I have the following Stream:
Stream
Stream stream = stream(); T result = stream.filter(t -> { double x = getX(t); double y = getY(
You can use Optional.orElse, it's much simpler than checking isPresent:
isPresent
T result = stream.filter(t -> { double x = getX(t); double y = getY(t); return (x == tx && y == ty); }).findFirst().orElse(null); return result;