Class CommaSeparated


  • public class CommaSeparated
    extends java.lang.Object
    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

      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
      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.
      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.
      java.lang.String build()
      Build and return the final string.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • CommaSeparated

        public CommaSeparated​(java.lang.String startString,
                              java.lang.String endString)
        Constructor.
        Parameters:
        startString - the starting string
        endString - the ending string
      • CommaSeparated

        public CommaSeparated​(java.lang.StringBuilder sb,
                              java.lang.String startString,
                              java.lang.String endString)
        Constructor.
        Parameters:
        sb - the StringBuilder to use
        startString - the starting string
        endString - 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:
        toString in class java.lang.Object