Objects.nonNull()

mark.reinhold at oracle.com mark.reinhold at oracle.com
Thu Jan 13 22:55:22 UTC 2011


> Date: Thu, 13 Jan 2011 17:11:37 -0500
> From: brian.goetz at oracle.com

> ...
> 
> One last question for Mark on the ensureXxx() convention: methods like
> ensureXxx() sometimes mean "make this true" (like ensureCapacity() in
> collections implementations) rather than "barf if it is not true."

Right.  Actually there are no public, exception-throwing ensureFoo(x)
methods, so I withdraw my suggestion.  (There are a bunch of private
ones.)

>                                                                     I'm willing
> to go either way (both checkNonNull and ensureNonNull better match the actual
> behavior of the method than plain nonNull) but we might as well pick the right
> convention.

Rémi's throwIfNull(x) suggestion does capture the precise meaning,
though it begs the question of what, exactly, will be thrown.

- Mark



More information about the core-libs-dev mailing list