Strings { public static String trimToEmpty(final String s) { final String trimmed = trim(s); if (trimmed == null || trimmed.isEmpty()) { return ""; } else { return trimmed; } } private  Strings(); static boolean isNull(final String s); static boolean isEmpty(final String s); static boolean isNotEmpty(final String s); static boolean isBlank(final String s); static String trim(final String s); static String trimToNull(final String s); static String trimToEmpty(final String s); static String toLowerCase(final String s);  }
@Test public void testTrimToEmpty() { final String nullString = null; final String emptyString = ""; final String blankString = " "; final String string = " a "; assertThat(Strings.trimToEmpty(nullString), is("")); assertThat(Strings.trimToEmpty(emptyString), is("")); assertThat(Strings.trimToEmpty(blankString), is("")); assertThat(Strings.trimToEmpty(string), is("a")); }