Package com.mapr.utils
Class CommaSeparated
java.lang.Object
com.mapr.utils.CommaSeparated
CommaSeparated provides an easy way to build comma separated lists
within a String or a StringBuilder. A comma separated list consists of
a beginning string, an ending string, and any number (including zero)
of elements in between them. If more than one element is added, then
a comma and a space are injected in between them.
-
Constructor Summary
ConstructorsConstructorDescriptionCommaSeparated(StringBuilder sb, String startString, String endString) Constructor.CommaSeparated(String startString, String endString) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionappend(char c) Append a character to the string being built up, prepending a comma and space if this is not the first item.Append a string to the string being built up, prepending a comma and space if this is not the first item.build()Build and return the final string.toString()
-
Constructor Details
-
CommaSeparated
Constructor.- Parameters:
startString- the starting stringendString- the ending string
-
CommaSeparated
Constructor.- Parameters:
sb- the StringBuilder to usestartString- the starting stringendString- the ending string
-
-
Method Details
-
append
Append a character to the string being built up, prepending a comma and space if this is not the first item.- Parameters:
c- the character to append- Returns:
- fluent-style this
-
append
Append a string to the string being built up, prepending a comma and space if this is not the first item.- Parameters:
s- the string to append- Returns:
- fluent-style this
-
build
Build and return the final string. No more items may be appended after this.- Returns:
- the finished string
-
toString
-