Class StringJoiner
java.lang.Object
ch.tocco.nice2.toolbox.api.string.StringJoiner
- All Implemented Interfaces:
Appendable
Deprecated.
String Builder class that supports automatic insertion of an in-between concatenation string.
Example usage:
StringJoiner sj = new StringJoiner(", ");
sj.append("tom").append("jones").get().toString();
It also features some static methods for simple tasks:
String s = StringJoiner.join(myCollection);
String s = StringJoiner.join(myCollection, ", ");
Not synchronized, relies on StringBuilder
.
-
Constructor Summary
ConstructorDescriptionDeprecated.Creates a new instance without a concatenation string to begin with.StringJoiner
(@Nullable String concat) Deprecated.Creates a new instance with a concatenation string.StringJoiner
(StringBuilder sb, @Nullable String concat) Deprecated.Creates a new instance with a concatenation string. -
Method Summary
Modifier and TypeMethodDescriptionappend
(char c) Deprecated.append
(CharSequence charSequence) Deprecated.append
(CharSequence charSequence, int i, int i1) Deprecated.Deprecated.Deprecated.Appends each element of an object.Deprecated.Appends each element of an object.Deprecated.Forces the string joiner to append the current concatenation string, if any.Deprecated.Voids (kills) any concatenation string, but does NOT reset the loop status.get()
Deprecated.Returns a reference to the StringBuilder in use.static String
Deprecated.static String
Deprecated.static String
Deprecated.static String
Deprecated.reset()
Deprecated.Resets the loop status, keeps the current concatenation string (if any).resetConcat
(@Nullable String concat) Deprecated.Resets the loop status and sets a new concatenation string.toString()
Deprecated.
-
Constructor Details
-
StringJoiner
Deprecated.Creates a new instance with a concatenation string.- Parameters:
sb
- A StringBuilder if you have one already.concat
- The concatenation string will be used from the 2nd call toappend(java.lang.CharSequence)
.
-
StringJoiner
Deprecated.Creates a new instance with a concatenation string. Overloaded method that creates a new StringBuilder.- Parameters:
concat
- The concatenation string will be used from the 2nd call toappend(java.lang.CharSequence)
.- See Also:
-
StringJoiner
public StringJoiner()Deprecated.Creates a new instance without a concatenation string to begin with. One may be set later usingresetConcat(java.lang.String)
. Overloaded method that creates a new StringBuilder.- See Also:
-
-
Method Details
-
clearConcat
Deprecated.Voids (kills) any concatenation string, but does NOT reset the loop status.- Returns:
- A reference to this StringJoiner.
-
reset
Deprecated.Resets the loop status, keeps the current concatenation string (if any). The concatenation string will be used again from the 2nd call toappend(java.lang.CharSequence)
.- Returns:
- A reference to this StringJoiner.
-
resetConcat
Deprecated.Resets the loop status and sets a new concatenation string.- Parameters:
concat
- The new concatenation string which will be used from the 2nd call toappend(java.lang.CharSequence)
.- Returns:
- A reference to this StringJoiner.
-
append
Deprecated.- Specified by:
append
in interfaceAppendable
-
append
Deprecated.- Specified by:
append
in interfaceAppendable
-
append
Deprecated.- Specified by:
append
in interfaceAppendable
-
append
Deprecated. -
appendAll
Deprecated.Appends each element of an object. Ignores null values.- Parameters:
objects
- The elements.- Returns:
- A reference to this StringJoiner.
-
appendAll
Deprecated.Appends each element of an object. Ignores null values. Overloaded method for Object[] (stupid java until se6).- Parameters:
objects
- The elements.- Returns:
- A reference to this StringJoiner.
-
appendConcat
Deprecated.Forces the string joiner to append the current concatenation string, if any.- Returns:
- A reference to this StringJoiner.
-
get
Deprecated.Returns a reference to the StringBuilder in use.- Returns:
- The internal builder, use it as output or for accessing its broader API.
-
toString
Deprecated. -
join
Deprecated. -
join
Deprecated. -
join
Deprecated. -
join
Deprecated.
-
Joiner