Class StringJoiner

java.lang.Object
dev.gmitch215.bytebox.text.StringJoiner

public final class StringJoiner extends Object
java.util.StringJoiner, which the class library does not carry.

Small, and it blocks more than its size suggests: it is what a good deal of ordinary joining code reaches for, so a library using it does not link at all without this.

Since:
1.0.2
  • Constructor Details

    • StringJoiner

      public StringJoiner(CharSequence separator)
      Parameters:
      separator - what goes between elements
    • StringJoiner

      public StringJoiner(CharSequence separator, CharSequence prefix, CharSequence suffix)
      Parameters:
      separator - what goes between elements
      prefix - what goes before the first
      suffix - what goes after the last
  • Method Details

    • add

      public StringJoiner add(CharSequence newElement)
      Parameters:
      newElement - the element to add
      Returns:
      this joiner
    • setEmptyValue

      public StringJoiner setEmptyValue(CharSequence emptyValue)
      Parameters:
      emptyValue - what to answer when nothing was added
      Returns:
      this joiner
    • merge

      public StringJoiner merge(StringJoiner other)
      Parameters:
      other - the joiner to append, without its prefix or suffix
      Returns:
      this joiner
    • length

      public int length()
      Returns how long the result would be.
      Returns:
      how long the result would be
    • toString

      public String toString()
      Overrides:
      toString in class Object