Class StringToCollectionConverter

java.lang.Object
com.vaadin.featurepack.data.converter.StringToCollectionConverter
All Implemented Interfaces:
Converter<String,Collection>, com.vaadin.flow.data.converter.Converter<String,Collection>, Serializable

public class StringToCollectionConverter extends Object implements Converter<String,Collection>
A converter that converts from String to Collection of tokens and back.

Allows to break a string into tokens using delimiter. Each token can be converted to its own model using provided converter.

Default constructor uses ", " as delimiter string and String for token types. Other constructors allow to configure delimiter and token types.

Author:
Vaadin Ltd
See Also:
  • Constructor Details

    • StringToCollectionConverter

      public StringToCollectionConverter()
      Creates converter with ", " as delimiter and String as token model type in collection.
    • StringToCollectionConverter

      public StringToCollectionConverter(String delimiter)
      Creates converter with given delimiter and String as token model type in collection.
      Parameters:
      delimiter - custom delimiter
    • StringToCollectionConverter

      public StringToCollectionConverter(Converter<String,?> tokenConverter, Class<?> tokenType)
      Creates converter with given tokenConverter for convert tokens and expected tokenType.

      If tokenConverter is null then no conversation is done and String is used as token type in resulting model collection.

      Parameters:
      tokenConverter - converter for token
      tokenType - expected token model type
    • StringToCollectionConverter

      public StringToCollectionConverter(String delimiter, Converter<String,?> tokenConverter, Class<?> tokenClass)
      Creates converter with given tokenConverter for convert tokens and expected tokenType.

      If tokenConverter is null then no conversation is done and String is used as token type in resulting model collection.

      Parameters:
      delimiter - delimiter in presentation string
      tokenConverter - converter for token
      tokenType - expected token model type
    • StringToCollectionConverter

      public StringToCollectionConverter(String delimiter, Converter<String,?> tokenConverter, Class<?> tokenClass, StringToCollectionConverter.CollectionFactory factory)
      Creates converter with given tokenConverter for convert tokens and expected tokenType.

      If tokenConverter is null then no conversation is done and String is used as token type in resulting model collection.

      Parameters:
      delimiter - delimiter in presentation string
      tokenConverter - converter for token
      factory - factory to create resulting collection
      tokenType - expected token model type
  • Method Details