List of utility methods to do StringJoiner Usage
String | joinRepeating(String element, String delimiter, int times) join Repeating StringJoiner joiner = new StringJoiner(delimiter); for (int i = 0; i < times; ++i) { joiner.add(element); return joiner.toString(); |
String | joinToString(String sep, Iterable join To String final StringJoiner j = new StringJoiner(sep); items.forEach(j::add); return j.toString(); |
String | listToString(List list To String if (list == null || list.isEmpty()) return null; StringJoiner joiner = new StringJoiner(",", "[", "]"); for (Object o : list) { if (o == null) joiner.add("null"); else joiner.add(o.toString()); ... |
void | print(int[] a)StringJoiner sj = new StringJoiner(",", "[", "]"); for (int i = 0; i < a.length; i++) { sj.add(String.valueOf(a[i])); System.out.println(sj.toString()); |
String | split(String s) split if (s == null || s.isEmpty()) { return s; StringJoiner joiner = new StringJoiner(" "); for (String word : s.split(RE_CAMELCASE_OR_UNDERSCORE)) { if (!word.isEmpty()) { joiner.add(word.trim()); return joiner.toString(); |
void | throwSafeguardError(String thisClassName, String thisMethodsName, String superClassName, String... namesOfMethodsWhoseDefaultImplementationUsesThisMethod) A utility method throwing an error to indicate that a method used by a default implementation of another method has not been overridden. String oneOf = namesOfMethodsWhoseDefaultImplementationUsesThisMethod.length > 1 ? "one of " : ""; throw new Error(thisMethodsName + " is being invoked but has not been overridden by " + thisClassName + ". " + "It is probably being invoked by the default implementation of " + oneOf + join(namesOfMethodsWhoseDefaultImplementationUsesThisMethod) + " in " + superClassName + ", unless some other overriding method invokes it. " + "If the default implementation of " + join(namesOfMethodsWhoseDefaultImplementationUsesThisMethod) + " in " + superClassName + " is being used, " + thisMethodsName + " should be overridden," + " or if " + thisMethodsName + " does not make sense for " + thisClassName ... |
String | toCVS(Set to CVS StringJoiner joiner = new StringJoiner(","); buildRecordSetIds.forEach(el -> joiner.add(el.toString())); return joiner.toString(); |