In any case, there already exist solutions in place:
https://checkerframework.org/manual/#example-use
https://github.com/uber/NullAway
Optional<Integer> foo; //.... if (foo != null) { foo.and_then(new Consumer () { function accept(Integer foo) { } }); }
To ensure assignment before use make it final.
In any case, there already exist solutions in place:
https://checkerframework.org/manual/#example-use
https://github.com/uber/NullAway