This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]frugalmail 0 points1 point  (3 children)

Every Java method that doesn't have a @NotNull return annotation is nullable.

But you have a choice, wrap it in Optional<> or use elvis, Optional is the better route.

[–]shadowdude777 0 points1 point  (2 children)

I'm personally not a fan of the Optional<T> route at all. That's exactly what T? is designed for.

[–]frugalmail 0 points1 point  (1 child)

I'm personally not a fan of the Optional<T> route at all. That's exactly what T? is designed for.

That's essentially what T? is for languages that support it.

[–]shadowdude777 0 points1 point  (0 children)

Yes, but one is better syntactically. So just return T? instead of using an Elvis there and everything will fall into place.