commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory" <ggreg...@seagullsoftware.com>
Subject RE: [lang] New StringUtils method - defaultIfEmpty
Date Fri, 01 Apr 2005 06:40:13 GMT
Agreed. 

FWIW, for this kind of method I kind of like the "return condition ? v1
: v2;" idiom.

Gary

-----Original Message-----
From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
Sent: Thursday, March 31, 2005 2:52 PM
To: Jakarta Commons Developers List
Subject: Re: [lang] New StringUtils method - defaultIfEmpty

It depends really on how you perceive the function, ie. which group of 
methods does it belong to.

I perceive this as an extension to the default* methods, as its just 
deaulting based on another condition.

trimToDefault isn't wrong, but its not where *I* would look for the
method.

Stephen

Gary Gregory wrote:
> It sounds OK but there might be a different (better?) way.
> 
> We now have trimToEmpty and trimToNull methods. What about a
> trimToDefault method?
> 
> Just a thought.
> 
> Gary
> 
> -----Original Message-----
> From: Stephen Colebourne [mailto:scolebourne@btopenworld.com] 
> Sent: Wednesday, March 30, 2005 2:29 PM
> To: Jakarta Commons Developers List
> Subject: [lang] New StringUtils method - defaultIfEmpty
> 
> Currently we have two default methods, both of which default when the 
> string parameter is null. At my job we just had need of a default if 
> empty method:
> 
> public String defaultIfEmpty(String str, String defaultString) {
>   if (isEmpty(str)) {
>    return defaultString;
>   } else {
>    return str;
>   }
> }
> 
> Does this sound OK to add?
> 
> Stephen
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 
> 

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



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


Mime
View raw message