Class CommaSeparated

java.lang.Object
com.mapr.utils.CommaSeparated

public class CommaSeparated extends 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 Details

    • CommaSeparated

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

      public CommaSeparated(StringBuilder sb, String startString, String endString)
      Constructor.
      Parameters:
      sb - the StringBuilder to use
      startString - the starting string
      endString - the ending string
  • Method Details

    • 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(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 String build()
      Build and return the final string. No more items may be appended after this.
      Returns:
      the finished string
    • toString

      public String toString()
      Overrides:
      toString in class Object