Objects.nonNull()

mark.reinhold at oracle.com mark.reinhold at oracle.com
Thu Jan 13 20:33:58 UTC 2011


> Date: Thu, 13 Jan 2011 15:06:54 -0500
> From: brian.goetz at oracle.com

> ...
> 
> I propose to change these to be called checkNonNull(), so their null-checking
> behavior is obvious to readers of code, ...

An even better name would be ensureNonNull(), which captures the notion
that if the method returns then the condition is ensured.  Just a "check"
leaves open the possibility of some less drastic behavior, such as merely
returning a boolean.

(For what it's worth, the ensureFoo() pattern is already used elsewhere.)

- Mark



More information about the core-libs-dev mailing list