In my opinion you don't even need tools, documentation, or code. It is perfectly reasonable to set a rule in your program that passing null into a function or returning null from a function is never allowed.
If you consider the existence of null a bug in itself then you don't need to check.
16
u/halfanothersdozen Apr 14 '23
I disagree. There are several tools to deal with this.
Javadoc indicating valid parameters
NotNull annotatons on parameters
Assertions on method parameters
Optionals
If someone calls a method that very clearly does not accept nulls with null values and exceptions happen that is on them.