Package com.mapr.utils
Class CommaSeparated
- java.lang.Object
-
- com.mapr.utils.CommaSeparated
-
public class CommaSeparated extends java.lang.ObjectCommaSeparated 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
Constructors Constructor Description CommaSeparated(java.lang.StringBuilder sb, java.lang.String startString, java.lang.String endString)Constructor.CommaSeparated(java.lang.String startString, java.lang.String endString)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommaSeparatedappend(char c)Append a character to the string being built up, prepending a comma and space if this is not the first item.CommaSeparatedappend(java.lang.String s)Append a string to the string being built up, prepending a comma and space if this is not the first item.java.lang.Stringbuild()Build and return the final string.java.lang.StringtoString()
-
-
-
Constructor Detail
-
CommaSeparated
public CommaSeparated(java.lang.String startString, java.lang.String endString)Constructor.- Parameters:
startString- the starting stringendString- the ending string
-
CommaSeparated
public CommaSeparated(java.lang.StringBuilder sb, java.lang.String startString, java.lang.String endString)Constructor.- Parameters:
sb- the StringBuilder to usestartString- the starting stringendString- the ending string
-
-
Method Detail
-
append
public CommaSeparated append(char c)
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
public CommaSeparated append(java.lang.String s)
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
public java.lang.String build()
Build and return the final string. No more items may be appended after this.- Returns:
- the finished string
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-