On 3/25/2016 1:43 AM, Andrej Golovnin wrote:
Hi Phil,
That is true .. although I think I have previously been convinced that IAE
is generally the better choice for such a case, I found only deriveFont
that throws IAE for null in this file.
So the question is whether to be consistent or to start picking the better
option.
So if there were no existing IAEs or NPEs in this file, which would you choose
now ?
From my standpoint of view you should use NPE.
And maybe java.util.Objects.requireNonNull() may help you to answer this
question
if you rewrite your code to use it instead of doing manual check. :-)
requireNonNull() just checks null value regardless of where is it found. While
the question is about about method argument values specifically.
I would be grateful to those who can prove why NPE is preferred to IAE in case
if the invalid argument value equals to null.
Best regards,
Andrej Golovnin