Strings { public static List<String> splitAndTrim(String value, String regex) { List<String> result = new ArrayList<>(); if (isNotBlank(value)) { String[] segements = value.split(regex); for (String segment : segements) { if (isNotBlank(segment)) { result.add(segment.trim()); } } } return result; }  static String join(Iterable<?> col, String separator); static boolean isBlank(String s); static boolean isNotBlank(String s); static boolean isEmpty(String s); static boolean isNotEmpty(String s); static List<String> splitAndTrim(String value, String regex); static String trim(String s); static String trimToNull(String s); static String joinClassNames(Iterable<?> iterable); static Boolean toBoolean(String s);  }
@Test void testSplitAndTrim() { assertEquals(0, Strings.splitAndTrim(null, ",").size()); assertEquals(0, Strings.splitAndTrim(" ", ",").size()); List<String> first = Strings.splitAndTrim(" ,foo", ","); assertEquals(1, first.size()); assertEquals("foo", first.get(0)); List<String> second = Strings.splitAndTrim(" foo,,,bar ", ","); assertEquals(2, second.size()); assertEquals("foo", second.get(0)); assertEquals("bar", second.get(1)); }