You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Stephen Colebourne <sc...@btopenworld.com> on 2009/11/17 10:33:56 UTC

[lang] Checking for NULL

The new ObjectUtils.firstNonNull() method checked for both null and the 
ObjectUtils.NULL constant object. Since that was the only method with 
that behaviour I removed the check for the NULL object.

The question is broader than that... do we want all null checks in 
ObjectUtils or [lang] to also check for ObjectUtils.NULL?

IMO, the NULL constant was intended for collections where null isn't 
valid. So I don't think I'd add broader checks.

Stephen


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


Re: [lang] Checking for NULL

Posted by Stephen Colebourne <sc...@btopenworld.com>.
Henri Yandell wrote:
> Agreed. I'd never read the javadoc which suggests collections usage
> and had assumed we had grander schemes.
> 
> Is ObjectUtils.NULL worth keeping?

I think ObjectUtils.NULL is worth keeping, but there should be two 
methods that do know about it:

public T wrapNull(T obj) {
   return obj != null ? obj : NULL;
}
public T unwrapNull(T obj) {
   return obj != NULL ? obj : null;
}

Stephen


> On Tue, Nov 17, 2009 at 3:01 AM, Paul Benedict <pb...@apache.org> wrote:
>> The use of ObjectUtils.NULL seems esoteric. If you didn't write this
>> email, I wouldn't have known of its support.
>>
>> Paul
>>
>> On Tue, Nov 17, 2009 at 3:33 AM, Stephen Colebourne
>> <sc...@btopenworld.com> wrote:
>>> The new ObjectUtils.firstNonNull() method checked for both null and the
>>> ObjectUtils.NULL constant object. Since that was the only method with that
>>> behaviour I removed the check for the NULL object.
>>>
>>> The question is broader than that... do we want all null checks in
>>> ObjectUtils or [lang] to also check for ObjectUtils.NULL?
>>>
>>> IMO, the NULL constant was intended for collections where null isn't valid.
>>> So I don't think I'd add broader checks.
>>>
>>> Stephen
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>>> For additional commands, e-mail: dev-help@commons.apache.org
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
> 
> 

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


Re: [lang] Checking for NULL

Posted by Henri Yandell <fl...@gmail.com>.
Agreed. I'd never read the javadoc which suggests collections usage
and had assumed we had grander schemes.

Is ObjectUtils.NULL worth keeping?

Hen

On Tue, Nov 17, 2009 at 3:01 AM, Paul Benedict <pb...@apache.org> wrote:
> The use of ObjectUtils.NULL seems esoteric. If you didn't write this
> email, I wouldn't have known of its support.
>
> Paul
>
> On Tue, Nov 17, 2009 at 3:33 AM, Stephen Colebourne
> <sc...@btopenworld.com> wrote:
>> The new ObjectUtils.firstNonNull() method checked for both null and the
>> ObjectUtils.NULL constant object. Since that was the only method with that
>> behaviour I removed the check for the NULL object.
>>
>> The question is broader than that... do we want all null checks in
>> ObjectUtils or [lang] to also check for ObjectUtils.NULL?
>>
>> IMO, the NULL constant was intended for collections where null isn't valid.
>> So I don't think I'd add broader checks.
>>
>> Stephen
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
>> For additional commands, e-mail: dev-help@commons.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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


Re: [lang] Checking for NULL

Posted by Paul Benedict <pb...@apache.org>.
The use of ObjectUtils.NULL seems esoteric. If you didn't write this
email, I wouldn't have known of its support.

Paul

On Tue, Nov 17, 2009 at 3:33 AM, Stephen Colebourne
<sc...@btopenworld.com> wrote:
> The new ObjectUtils.firstNonNull() method checked for both null and the
> ObjectUtils.NULL constant object. Since that was the only method with that
> behaviour I removed the check for the NULL object.
>
> The question is broader than that... do we want all null checks in
> ObjectUtils or [lang] to also check for ObjectUtils.NULL?
>
> IMO, the NULL constant was intended for collections where null isn't valid.
> So I don't think I'd add broader checks.
>
> Stephen
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>

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