Class StringBuilderJoiner

java.lang.Object
org.faktorips.runtime.util.StringBuilderJoiner

public class StringBuilderJoiner extends Object
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 Details

  • Method Details

    • join

      public static final void join(StringBuilder sb, Iterable<?> iterable, String separator)
      Appends the elements of the provided Iterable to the given StringBuilder, separated by the given separator. No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      iterable - the Collection of values to join together, may be null
      separator - the separator to use, null treated as ""
    • join

      public static final void join(StringBuilder sb, Iterable<?> iterable)
      Appends the elements of the provided Iterable to the given StringBuilder, separated by the DEFAULT_SEPARATOR ", ". No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      iterable - the Collection of values to join together, may be null
    • join

      public static final void join(StringBuilder sb, Object[] objectArray)
      Appends the elements of the provided array to the given StringBuilder, separated by the DEFAULT_SEPARATOR ", ". No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      objectArray - the array of values to join together, may be null
    • join

      public static final <T> void join(StringBuilder sb, Iterable<T> iterable, Consumer<? super T> singleItemAppender)
      Appends the elements of the provided Iterable, converted to String with the given toString Function, to the given StringBuilder, separated by the DEFAULT_SEPARATOR ", ". No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      iterable - the Collection of values to join together, may be null
      singleItemAppender - a Consumer that takes a single element to append it with multiple calls to StringBuilder.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 given toString Function, to the given StringBuilder, separated by the DEFAULT_SEPARATOR ", ". No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      objectArray - the array of values to join together, may be null
      singleItemAppender - a Consumer that takes a single element to append it with multiple calls to StringBuilder.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 provided Iterable, converted to String with the given toString Function, to the given StringBuilder, separated by the given separator. No delimiter is added before or after the list.
      Parameters:
      sb - the StringBuilder to which the values will be appended
      iterable - the Collection of values to join together, may be null
      separator - the separator to use, null treated as ""
      singleItemAppender - a Consumer that takes a single element to append it with multiple calls to StringBuilder.append(String)