DEV Community

Discussion on: Consistent null values handling in Java

Collapse
 
chaoyang profile image
Chao Yang

So in this sense, basically we can see only one type: Option, everything, Object field, parameter, return value. The only place we can use the plain type is method body.

It sounds overkilled.

Collapse
 
siy profile image
Sergiy Yevtushenko

Didn't get it. Why we should see Option everywhere? If we sure that value can't be null, then we use plain type. It can be either, method body, parameter or field.

Collapse
 
isicju profile image
Dmitry Egorov

checkerframework.org/ is pretty verbose and force you to mark methods/fields with nullable/notnullable but can be integrated in compilation process and won't let you to miss potential NPE.

Collapse
 
siy profile image
Sergiy Yevtushenko

Thanks for the reference, I'll definitely take a look.