Package dev.gmitch215.bytebox.text
Class StringJoiner
java.lang.Object
dev.gmitch215.bytebox.text.StringJoiner
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 Summary
ConstructorsConstructorDescriptionStringJoiner(CharSequence separator) StringJoiner(CharSequence separator, CharSequence prefix, CharSequence suffix) -
Method Summary
Modifier and TypeMethodDescriptionadd(CharSequence newElement) intlength()Returns how long the result would be.merge(StringJoiner other) setEmptyValue(CharSequence emptyValue) toString()
-
Constructor Details
-
StringJoiner
- Parameters:
separator- what goes between elements
-
StringJoiner
- Parameters:
separator- what goes between elementsprefix- what goes before the firstsuffix- what goes after the last
-
-
Method Details
-
add
- Parameters:
newElement- the element to add- Returns:
- this joiner
-
setEmptyValue
- Parameters:
emptyValue- what to answer when nothing was added- Returns:
- this joiner
-
merge
- 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
-