diff --git a/src/java/com/samskivert/util/StringUtil.java b/src/java/com/samskivert/util/StringUtil.java index 7733bb8c..fd8017bb 100644 --- a/src/java/com/samskivert/util/StringUtil.java +++ b/src/java/com/samskivert/util/StringUtil.java @@ -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'