Class 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 Detail

      • parent

        private final Formatter<? super I> parent
      • separator

        private final String separator
      • skipNull

        private final boolean skipNull
    • Constructor Detail

      • 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 Detail

      • 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