Class AbstractStringToSequence<T>

  • Type Parameters:
    T - The sequence type.
    All Implemented Interfaces:
    Converter<String,​T>, Function<String,​T>
    Direct Known Subclasses:
    StringToArray, StringToList

    public abstract class AbstractStringToSequence<T>
    extends AbstractSequenceConverter<String,​T>
    Base class used to convert a string to a sequence.

    A sequence is converted to: (prefix) item separator item separator ... (suffix)
    If trim is set, then each item string representation is trimmed before being converted to item.
    prefix and suffix are optional.
    separator must be mandatory for this class to be useful.

    Author:
    Damien Carbonne
    • Constructor Detail

      • AbstractStringToSequence

        public AbstractStringToSequence​(Class<T> targetClass,
                                        String prefix,
                                        String separator,
                                        String suffix,
                                        boolean trim)
    • Method Detail

      • getTrim

        public final boolean getTrim()
      • toList

        protected <V> List<V> toList​(String s,
                                     Function<String,​? extends V> converter)
        Converts the string to a list of items.

        This works when separator is mandatory.

        Type Parameters:
        V - The item type.
        Parameters:
        s - The string.
        converter - The converter from string to V.
        Returns:
        A list of items after interpreting s with prefix, suffix, separator and trim.