The idea of Optional is not to prevent all
NPEs. The idea is to make it clear that an API
method can return an absent value, and to force
the caller to be aware of that and deal with it.
Of course, if this method returns null instead
of an Optional, you'll still get a NPE, but that's
a giant design issue. A method returning an
Optional should return an Optional (present or
absent), not null.
And it's much more natural, in a OO language,
to access the state of an object using methods of
this object rather than a static method.