MedwynLiang / google-collections

Automatically exported from code.google.com/p/google-collections
Apache License 2.0
0 stars 0 forks source link

Preconditions.checkArgumentNotNull #294

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I was expecting Preconditions.checkNotNull to throw IllegalArgumentExceptions 
rather than npe's. In other words, I expected it to be a convenience method 
for checkArgument(foo != null).

Because sometimes when you do these API 'perimeter' checks, the fact that a 
given argument is illegal is more important than the fact that it is null, 
and I end up doing checkArgument(foo != null) frequently.

So I was thinking that Preconditions.checkArgumentNotNull might be a useful.

Original issue reported on code.google.com by jvdne...@gmail.com on 10 Nov 2009 at 5:30

GoogleCodeExporter commented 9 years ago
Throwing IAE for null arguments makes plenty of sense, however we're already 
saddled 
with years of convention favoring NPE.  At Google there was a time several 
years ago 
when the IAE proponents tried to stage a coup and convert anyone else, but it 
was 
just too late.

And, unfortunately I don't believe users will be well-served by a further 
explosion 
in the number of methods in the Preconditions class.  Adding more confusion 
about 
which they're supposed to use, and adding more variation of strategies 
throughout 
their codebase. I know it's sad, considering the void return type, but I think 
checkArgument(foo != null) will just have to serve.

Original comment by kevin...@gmail.com on 10 Nov 2009 at 6:31

GoogleCodeExporter commented 9 years ago
Fair enough

Original comment by jvdne...@gmail.com on 10 Nov 2009 at 7:31