Make Strings more like Options.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2558 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -121,6 +121,14 @@ public class StringUtil
|
||||
return truncate(s, maxLength, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the string if it is non-blank (see {@link #isBlank}), the default value otherwise.
|
||||
*/
|
||||
public static String getOr (String value, String defval)
|
||||
{
|
||||
return isBlank(value) ? defval : value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate the specified String if it is longer than maxLength. The string will be truncated
|
||||
* at a position such that it is maxLength chars long after the addition of the 'append'
|
||||
|
||||
Reference in New Issue
Block a user