You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Henri Yandell <fl...@gmail.com> on 2009/09/07 21:25:58 UTC

Re: ArrayList nullIfEmpty

(Presumably the title was meant to be ArrayUtils nullIfEmpty :) )

Best way is to open a JIRA issue up
(http://issues.apache.org/jira/browse/LANG).

The below should be defaultIfEmpty rather than nullIfEmpty I suspect
to match StringUtils/ObjectUtils.

Hen

On Thu, Aug 27, 2009 at 6:48 PM, Guy Rouillier<gu...@burntmail.com> wrote:
> I'm new to this list.  I searched the archives and could not find the
> subject method discussed.  Has it ever been proposed?  StringUtils has
> defaultIfEmpty, and ObjectUtils has defaultIfNull, but ObjectUtils doesn't
> have anything similar.  Since ArrayUtils already has all the necessary
> isEmtpy methods defined, the following would appear to be sufficient:
>
> public static <T> T[] nullIfEmpty(T[] array) {
>  return(isEmpty(array));
> }
>
> Thanks.
>
> --
> Guy Rouillier
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>

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


Re: ArrayList nullIfEmpty

Posted by Guy Rouillier <gu...@burntmail.com>.
Henri Yandell wrote:
> (Presumably the title was meant to be ArrayUtils nullIfEmpty :) )

Yes, thanks for reading my mind.  In the body, I also said ObjectUtils 
where I meant ArrayUtils :(.  So many different Utils I got myself 
twisted around.

> 
> Best way is to open a JIRA issue up
> (http://issues.apache.org/jira/browse/LANG).

I'll open the Jira issue.


> The below should be defaultIfEmpty rather than nullIfEmpty I suspect
> to match StringUtils/ObjectUtils.

I thought about that, but there doesn't appear to be any reasonable 
default for arrays other than null.  I don't object to default though, 
as for my purposes I can simply pass null for the default.

> 
> Hen
> 
> On Thu, Aug 27, 2009 at 6:48 PM, Guy Rouillier<gu...@burntmail.com> wrote:
>> I'm new to this list.  I searched the archives and could not find the
>> subject method discussed.  Has it ever been proposed?  StringUtils has
>> defaultIfEmpty, and ObjectUtils has defaultIfNull, but ObjectUtils doesn't
>> have anything similar.  Since ArrayUtils already has all the necessary
>> isEmtpy methods defined, the following would appear to be sufficient:
>>
>> public static <T> T[] nullIfEmpty(T[] array) {
>>  return(isEmpty(array));
>> }
>>
>> Thanks.
>>
>> --
>> Guy Rouillier
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
>> For additional commands, e-mail: user-help@commons.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
> 
> 


-- 
Guy Rouillier

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