Binder
.forField(...).withConverter(...)
methods.@Deprecated public class StringToCollectionConverter extends Object implements Converter<String,Collection>
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.
Modifier and Type | Class and Description |
---|---|
static interface |
StringToCollectionConverter.CollectionFactory
Deprecated.
|
static class |
StringToCollectionConverter.DefaultCollectionFactory
Deprecated.
|
Converter.ConversionException
Constructor and Description |
---|
StringToCollectionConverter()
Deprecated.
Creates converter with
", " as delimiter and String
as token model type in collection. |
StringToCollectionConverter(Converter<String,?> tokenConverter,
Class<?> tokenType)
Deprecated.
Creates converter with given
tokenConverter for convert tokens
and expected tokenType . |
StringToCollectionConverter(String delimiter)
Deprecated.
Creates converter with given
delimiter and String as
token model type in collection. |
StringToCollectionConverter(String delimiter,
Converter<String,?> tokenConverter,
Class<?> tokenClass)
Deprecated.
Creates converter with given
tokenConverter for convert tokens
and expected tokenType . |
StringToCollectionConverter(String delimiter,
Converter<String,?> tokenConverter,
Class<?> tokenClass,
StringToCollectionConverter.CollectionFactory factory)
Deprecated.
Creates converter with given
tokenConverter for convert tokens
and expected tokenType . |
Modifier and Type | Method and Description |
---|---|
Collection |
convertToModel(String value,
Class<? extends Collection> targetType,
Locale locale)
Deprecated.
Converts the given value from target type to source type.
|
String |
convertToPresentation(Collection value,
Class<? extends String> targetType,
Locale locale)
Deprecated.
Converts the given value from source type to target type.
|
Class<Collection> |
getModelType()
Deprecated.
The source type of the converter.
|
Class<String> |
getPresentationType()
Deprecated.
The target type of the converter.
|
public StringToCollectionConverter()
", "
as delimiter and String
as token model type in collection.public StringToCollectionConverter(String delimiter)
delimiter
and String
as
token model type in collection.delimiter
- custom delimiterpublic StringToCollectionConverter(Converter<String,?> tokenConverter, Class<?> tokenType)
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.
tokenConverter
- converter for tokentokenType
- expected token model typepublic StringToCollectionConverter(String delimiter, Converter<String,?> tokenConverter, Class<?> tokenClass)
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.
tokenConverter
- converter for tokentokenClass
- expected token model typedelimiter
- delimiter in presentation stringpublic StringToCollectionConverter(String delimiter, Converter<String,?> tokenConverter, Class<?> tokenClass, StringToCollectionConverter.CollectionFactory factory)
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.
tokenConverter
- converter for tokentokenClass
- expected token model typedelimiter
- delimiter in presentation stringfactory
- factory to create resulting collectionpublic Class<Collection> getModelType()
Converter
Converter.convertToPresentation(Object, Class, Locale)
.getModelType
in interface Converter<String,Collection>
public Class<String> getPresentationType()
Converter
Converter.convertToModel(Object, Class, Locale)
.getPresentationType
in interface Converter<String,Collection>
public Collection convertToModel(String value, Class<? extends Collection> targetType, Locale locale) throws Converter.ConversionException
Converter
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
and
Converter.convertToModel(Object, Class, Locale)
should return the original
value.convertToModel
in interface Converter<String,Collection>
value
- The value to convert, compatible with the target type. Can be
nulltargetType
- The requested type of the return valuelocale
- The locale to use for conversion. Can be null.Converter.ConversionException
- If the value could not be convertedpublic String convertToPresentation(Collection value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException
Converter
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
and
Converter.convertToModel(Object, Class, Locale)
should return the original
value.convertToPresentation
in interface Converter<String,Collection>
value
- The value to convert, compatible with the target type. Can be
nulltargetType
- The requested type of the return valuelocale
- The locale to use for conversion. Can be null.Converter.ConversionException
- If the value could not be convertedCopyright © 2020 Vaadin Ltd. All rights reserved.