commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dIon Gillard <d...@multitask.com.au>
Subject Re: [httpclient] question regarding NameValuePair constructor, null parameters
Date Sun, 10 Feb 2002 14:32:57 GMT
Sean C. Sullivan wrote:

>Jakarta-commons HttpClient inquiry:
>
>Why does the NameValuePair constructor allow
>null parameters?
>
>This is how the code currently looks:
>
>NameValuePair.java
>
>--------------------------
>
>    /**
>     * Constructor.
>     */
>    public NameValuePair(String name, String value) {
>
>        this.name = name;
>        this.value = value;
>
>    }
>
>--------------------------
>
>With this constructor, it is allowable for a caller to do this:
>
>    NameValuePair nvp = new NameValuePair(null, null);
>
>I would prefer if the NameValuePair constructor did not allow null parameters.
>
>I prefer this constructor:
>
>    /**
>     * Constructor.
>     */
>    public NameValuePair(String name, String value) {
>
>        if (null == name) {
>            throw new NullPointerException("name parameter is null");
>        }
>        if (null == value) {
>            throw new NullPointerException("value parameter is null");
>        }
> 
>        this.name = name;
>        this.value = value;
>
>    }
>
>
Again,

my call would be if these are illegal arguments, it should throw 
IllegalArgumentException, not NullPointerException.

-- 
dIon Gillard, Multitask Consulting
http://www.multitask.com.au/developers





--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message