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:[EMAIL PROTECTED] 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to