@Test public void testCoalesce() { assertEquals("ok",StringUtils.coalesce("ok", "fail")); assertEquals("ok",StringUtils.coalesce(" \r \n \t ", "ok")); assertEquals("ok",StringUtils.coalesce(null, "ok")); assertEquals(null,StringUtils.coalesce(null, null)); }
public static String coalesce(String preferred, String alternative) { return isNotEmpty(preferred) ? preferred : alternative; }
StringUtils { public static String coalesce(String preferred, String alternative) { return isNotEmpty(preferred) ? preferred : alternative; } }
StringUtils { public static String coalesce(String preferred, String alternative) { return isNotEmpty(preferred) ? preferred : alternative; } private  StringUtils(); }
StringUtils { public static String coalesce(String preferred, String alternative) { return isNotEmpty(preferred) ? preferred : alternative; } private  StringUtils(); static String toString(Object value, String defValue); static String toString(Object value); static String toString(Object[] array, String defValue); static String toString(Object[] array); static String valueOf(Object value); static String valueOf(Object[] array); static String coalesce(String preferred, String alternative); static String nullIfEmpty(Object value); static boolean contains(String value, String substring); static boolean notContains(String value, String substring); static String arrayToString(Object[] array, String separator); static boolean isEmpty(String s); static boolean isNotEmpty(String s); static boolean compareEqual(String s1, String s2, boolean ignoreCase); static boolean compareEqual(String s1, String s2); static boolean compareNotEqual(String s1, String s2, boolean ignoreCase); static boolean compareNotEqual(String s1, String s2); static String validate(String s); static String replace(String source, String find, String replace); static String replaceAll(String s, String find, String replace); static String remove(String s, String remove); static String remove(String s, char c); static String removeBlanks(String s); static boolean isCharBetween(char c, char beg, char end); static boolean isNumber(char c); static boolean isNumber(String s); static boolean isNumeric(char c, boolean decimal); static boolean isNumeric(String s, boolean decimal); static boolean isUpper(char c); static boolean isUpper(String s, int count); static boolean isLower(char c); static boolean isLower(String s, int count); static String toUpper(String s, int count); static String toLower(String s, int count); }
StringUtils { public static String coalesce(String preferred, String alternative) { return isNotEmpty(preferred) ? preferred : alternative; } private  StringUtils(); static String toString(Object value, String defValue); static String toString(Object value); static String toString(Object[] array, String defValue); static String toString(Object[] array); static String valueOf(Object value); static String valueOf(Object[] array); static String coalesce(String preferred, String alternative); static String nullIfEmpty(Object value); static boolean contains(String value, String substring); static boolean notContains(String value, String substring); static String arrayToString(Object[] array, String separator); static boolean isEmpty(String s); static boolean isNotEmpty(String s); static boolean compareEqual(String s1, String s2, boolean ignoreCase); static boolean compareEqual(String s1, String s2); static boolean compareNotEqual(String s1, String s2, boolean ignoreCase); static boolean compareNotEqual(String s1, String s2); static String validate(String s); static String replace(String source, String find, String replace); static String replaceAll(String s, String find, String replace); static String remove(String s, String remove); static String remove(String s, char c); static String removeBlanks(String s); static boolean isCharBetween(char c, char beg, char end); static boolean isNumber(char c); static boolean isNumber(String s); static boolean isNumeric(char c, boolean decimal); static boolean isNumeric(String s, boolean decimal); static boolean isUpper(char c); static boolean isUpper(String s, int count); static boolean isLower(char c); static boolean isLower(String s, int count); static String toUpper(String s, int count); static String toLower(String s, int count);  }