StringLibrary { public static List<String> split(String chainedStrings, Character character) { return split(chainedStrings, format("[%c]", character)); }  static String unique(String string); static String quoted(String string); static List<String> split(String chainedStrings, Character character); static List<String> split(String chainedStrings, String splittingRegex); static String join(Collection<String> subStrings, Character connector); static String join(Collection<String> subStrings, String connector); static String stripEnd(String string, String suffix); static String firstAfterSplit(String string, Character character); static String firstAfterSplit(String string, String splittingRegex); static String lastAfterSplit(String string, Character character); static String lastAfterSplit(String string, String splittingRegex); static String reversed(String string); static List<String> toStringList(Collection<? extends Object> objects); static List<String> toStringList(Collection<? extends Object> objects, String nullString); static Map<String, String> asStringMap(Map<K, V> sourceMap); static Map<String, V> mapWithStringKeys(Map<K, V> sourceMap); static Map<K, String> mapWithStringValues(Map<K, V> sourceMap); static int maximumToStringLength(Collection<? extends Object> objects, int lengthOfNullToString); static String rightFilled(String string, int targetLength, Character filler); static Collection<String> rightFilled(Collection<String> strings, int targetLength, Character filler); static String leftFilled(String string, int targetLength, Character filler); static Collection<String> leftFilled(Collection<String> strings, int targetLength, Character filler); static String repeated(Character character, int times); static String repeated(String text, int times); static String plainDecimalRepresentation(Number number);  }
@Test public void stringSplit() { String chained = "aja~adja!~ao"; List<String> splitted; splitted = split(chained, "z"); assertEquals(1, splitted.size()); assertEquals(chained, splitted.get(0)); splitted = split(chained, "~"); assertEquals(3, splitted.size()); assertEquals("aja", splitted.get(0)); assertEquals("adja!", splitted.get(1)); assertEquals("ao", splitted.get(2)); splitted = split(chained, "ad.a"); assertEquals(2, splitted.size()); assertEquals("aja~", splitted.get(0)); assertEquals("!~ao", splitted.get(1)); }
@Test public void stringSplitWithCharacter() { String chained = "a.b.b.b,cc-dd(aa"; List<String> splitted; splitted = split(chained, '.'); assertEquals(4, splitted.size()); assertEquals("a", splitted.get(0)); assertEquals("b", splitted.get(1)); assertEquals("b", splitted.get(2)); assertEquals("b,cc-dd(aa", splitted.get(3)); splitted = split(chained, ','); assertEquals(2, splitted.size()); assertEquals("a.b.b.b", splitted.get(0)); assertEquals("cc-dd(aa", splitted.get(1)); splitted = split(chained, '('); assertEquals(2, splitted.size()); assertEquals("a.b.b.b,cc-dd", splitted.get(0)); assertEquals("aa", splitted.get(1)); splitted = split(chained, '+'); assertEquals(1, splitted.size()); assertEquals(chained, splitted.get(0)); }