Package org.faktorips.runtime.util
Class StringBuilderJoiner
java.lang.Object
org.faktorips.runtime.util.StringBuilderJoiner
Utility class similar to
StringJoiner / String.join(CharSequence, Iterable) /
Collectors.joining(CharSequence) that does not create intermediary Strings but appends
all parts to a preexisting StringBuilder.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidjoin(StringBuilder sb, Iterable<?> iterable) Appends the elements of the providedIterableto the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ".static final voidjoin(StringBuilder sb, Iterable<?> iterable, String separator) Appends the elements of the providedIterableto the givenStringBuilder, separated by the given separator.static final <T> voidjoin(StringBuilder sb, Iterable<T> iterable, String separator, Consumer<? super T> singleItemAppender) Appends the elements of the providedIterable, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by the given separator.static final <T> voidjoin(StringBuilder sb, Iterable<T> iterable, Consumer<? super T> singleItemAppender) Appends the elements of the providedIterable, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ".static final voidjoin(StringBuilder sb, Object[] objectArray) Appends the elements of the provided array to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ".static final <T> voidjoin(StringBuilder sb, T[] objectArray, Consumer<? super T> singleItemAppender) Appends the elements of the provided array, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ".
-
Field Details
-
DEFAULT_SEPARATOR
- See Also:
-
-
Method Details
-
join
Appends the elements of the providedIterableto the givenStringBuilder, separated by the given separator. No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendediterable- the Collection of values to join together, may benullseparator- the separator to use, null treated as ""
-
join
Appends the elements of the providedIterableto the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ". No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendediterable- the Collection of values to join together, may benull
-
join
Appends the elements of the provided array to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ". No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendedobjectArray- the array of values to join together, may benull
-
join
public static final <T> void join(StringBuilder sb, Iterable<T> iterable, Consumer<? super T> singleItemAppender) Appends the elements of the providedIterable, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ". No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendediterable- the Collection of values to join together, may benullsingleItemAppender- aConsumerthat takes a single element to append it with multiple calls toStringBuilder.append(String)
-
join
public static final <T> void join(StringBuilder sb, T[] objectArray, Consumer<? super T> singleItemAppender) Appends the elements of the provided array, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by theDEFAULT_SEPARATOR", ". No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendedobjectArray- the array of values to join together, may benullsingleItemAppender- aConsumerthat takes a single element to append it with multiple calls toStringBuilder.append(String)
-
join
public static final <T> void join(StringBuilder sb, Iterable<T> iterable, String separator, Consumer<? super T> singleItemAppender) Appends the elements of the providedIterable, converted to String with the giventoStringFunction, to the givenStringBuilder, separated by the given separator. No delimiter is added before or after the list.- Parameters:
sb- theStringBuilderto which the values will be appendediterable- the Collection of values to join together, may benullseparator- the separator to use, null treated as ""singleItemAppender- aConsumerthat takes a single element to append it with multiple calls toStringBuilder.append(String)
-