StringUtils { public static String trimToNull(String s) { if (s == null) { return null; } String temp = trimToEmpty(s); return EMPTY.equals(temp) ? null : temp; } private  StringUtils(); static Pair pair(String left, String right); static String truncate(String s, int length, boolean addDots); static String trimToEmpty(String s); static String trimToNull(String s); static String repeat(char c, int count); static String join(Object[] a, char delimiter); static String join(Collection<String> c, char delimiter); static List<String> split(String s, char delimiter, boolean skipBackSlash); static boolean isBlank(String s); static String toIdString(String name); static StringUtils.Pair splitByFirstLineFeed(String text); static List<String> toStringLines(String text); static int countLineFeeds(String text); static int wrappedLinesEstimate(String text, int colWidth); static boolean isJavaScriptFunction(String text); static String fixJavaScriptFunction(String text);  }
@Test public void testTrimToNull() { assertNull(StringUtils.trimToNull(null)); assertNull(StringUtils.trimToNull(" ")); assertEquals("foo", StringUtils.trimToNull(" foo ")); }