Code review: 7012540 (java.util.Objects.nonNull() incorrectly named)

Jeff Hain jeffhain at rocketmail.com
Wed Jan 26 15:37:59 UTC 2011


Hello.

As Ulf said, I think "requireNonNull" could be the name of a method that just
checks that the specified reference is not null, and would not return anything
(even though we could rather use "checkNonNull" in that case, and make it
return true if non null).

Though, "notNullChecked" or "nonNullChecked" might seem to suppose
that the non-nullity of the specified value has already being checked.

A more appropriate name would be "checkNonNullAndReturnIt", but it's too 
verbose.

I'm considering "beingNonNull" as an alternative, for "beingNonNull(x)" contains
the idea that it is still "x", i.e. that it normally returns "x", and that it 
supposes "x"
to be non null, i.e. that it checks it.
Also, the passive form "being" contains the idea that we don't change anything 
to
the value.

An alternative to this alternative would be "notBeingNull", which would be more 
on
pair with methods like "beingPrime"/"notBeingPrime" ("beingNonPrime" looking
weird to me).


Though, verbs in passive form in methods names might look strange to a lot of 
people.

Regards,

Jeff.



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/core-libs-dev/attachments/20110126/1c021f09/attachment.html>


More information about the core-libs-dev mailing list