On Thu, Jan 27, 2011 at 2:20 AM, Bob Lee <crazy...@crazybob.org> wrote: > On Wed, Jan 26, 2011 at 3:44 PM, Joshua Bloch <j...@google.com> wrote: >> >> I like the name nonNull. All other things being equal, shorter is better. >> I've used the name nonNull for a few years, and it's feels right. To my >> mind, requireNonNull does a worse job of suggesting that the method returns >> its argument. > > +1 for nonNull. While it's implemented as a method, I think of it more as a > keyword-like modifier, in which case an adjective works better than a verb > phrase. > Bob
Couldn't agree more. I'm surprised no one has brought up the analogy to type casts yet. nonNull(o) is the equivalent of (String)o. It is a static assertion that the static type system is too weak to express and that may fail at runtime; programmers familiar with the Java language do not expect (String)o to perform a value conversion either. -- Matthias nonNullOrBust.