💾 Archived View for heavysquare.com › notes › BEE9-nullable-to-optional-in-java.txt captured on 2023-03-20 at 17:50:10.

View Raw

More Information

⬅️ Previous capture (2022-04-28)

-=-=-=-=-=-=-


~~ 2021-12-14T12:52:04+01:00

So you want to be a good guy and you turn a "nullable" field to
Optional<> (or vavr.Option<>).

Optional<> values could be null as well, so your compiler won't flag
any of your ==null checks. You need to somehow discover them
yourself.

Thank you very much.

Problem is when you check for nullity then pass the value further down
the stack. Finally when you use it, it'll fail compilation, but will
have no context if the value is "guaranteed" not to be null.