Class CollectionFormatter<I>

java.lang.Object
net.sf.basedb.util.formatter.CollectionFormatter<I>
All Implemented Interfaces:
Formatter<Collection<I>>

public class CollectionFormatter<I> extends Object implements Formatter<Collection<I>>
Formatter implementation that formats a collection of values to a string by concatenating the values with a given separator. Reverse parsing is not supported.
Since:
3.16
Author:
nicklas
  • Field Details

    • parent

      private final Formatter<? super I> parent
    • separator

      private final String separator
    • skipNull

      private final boolean skipNull
  • Constructor Details

    • CollectionFormatter

      public CollectionFormatter(Formatter<? super I> parent)
      Create a collection formatting using ", " as separator and skipping null values.
    • CollectionFormatter

      public CollectionFormatter(String separator, boolean skipNull, Formatter<? super I> parent)
  • Method Details

    • format

      public String format(Collection<I> values)
      Description copied from interface: Formatter
      Format a value by converting it to a string.
      Specified by:
      format in interface Formatter<I>
      Parameters:
      values - The value to format
      Returns:
      A formatted string
    • parseString

      public Collection<I> parseString(String value)
      Description copied from interface: Formatter
      Parse a string and return a value of the correct type. A null input string should (unless otherwise documented by a specific formatter implementation) be allowed and may return null or any other "default" value.
      Specified by:
      parseString in interface Formatter<I>
      Parameters:
      value - The string to parse
      Returns:
      An object