public class ConverterUtil extends Object implements Serializable
| Constructor and Description |
|---|
ConverterUtil() |
| Modifier and Type | Method and Description |
|---|---|
static boolean |
canConverterHandle(Converter<?,?> converter,
Class<?> presentationType,
Class<?> modelType)
Checks if the given converter can handle conversion between the given
presentation and model type.
|
static boolean |
canConverterPossiblyHandle(Converter<?,?> converter,
Class<?> presentationType,
Class<?> modelType)
Checks if it possible that the given converter can handle conversion
between the given presentation and model type somehow.
|
static <PRESENTATIONTYPE,MODELTYPE> |
convertFromModel(MODELTYPE modelValue,
Class<? extends PRESENTATIONTYPE> presentationType,
Converter<PRESENTATIONTYPE,MODELTYPE> converter,
Locale locale)
Convert the given value from the data source type to the UI type.
|
static <MODELTYPE,PRESENTATIONTYPE> |
convertToModel(PRESENTATIONTYPE presentationValue,
Class<MODELTYPE> modelType,
Converter<PRESENTATIONTYPE,MODELTYPE> converter,
Locale locale)
Convert the given value from the presentation (UI) type to model (data
source) type.
|
static <PRESENTATIONTYPE,MODELTYPE> |
getConverter(Class<PRESENTATIONTYPE> presentationType,
Class<MODELTYPE> modelType,
VaadinSession session)
Finds a converter that can convert from the given presentation type to
the given model type and back.
|
public static <PRESENTATIONTYPE,MODELTYPE> Converter<PRESENTATIONTYPE,MODELTYPE> getConverter(Class<PRESENTATIONTYPE> presentationType, Class<MODELTYPE> modelType, VaadinSession session)
ConverterFactory or, if application is null, uses the
VaadinSession.getCurrent().PRESENTATIONTYPE - the presentation typeMODELTYPE - the model typepresentationType - the presentation typemodelType - the model typesession - the session to use to find a ConverterFactory or null to use
the current sessionpublic static <PRESENTATIONTYPE,MODELTYPE> PRESENTATIONTYPE convertFromModel(MODELTYPE modelValue,
Class<? extends PRESENTATIONTYPE> presentationType,
Converter<PRESENTATIONTYPE,MODELTYPE> converter,
Locale locale)
throws Converter.ConversionException
PRESENTATIONTYPE - the presentation typeMODELTYPE - the model typemodelValue - the model value to convertpresentationType - the type of the presentation valueconverter - the converter to uselocale - the locale to use for conversionConverter.ConversionException - if there was a problem converting the valuepublic static <MODELTYPE,PRESENTATIONTYPE> MODELTYPE convertToModel(PRESENTATIONTYPE presentationValue,
Class<MODELTYPE> modelType,
Converter<PRESENTATIONTYPE,MODELTYPE> converter,
Locale locale)
throws Converter.ConversionException
PRESENTATIONTYPE - the presentation typeMODELTYPE - the model typepresentationValue - the presentation value to convertmodelType - the type of the modelconverter - the converter to uselocale - the locale to use for conversionConverter.ConversionException - if there was a problem converting the valuepublic static boolean canConverterHandle(Converter<?,?> converter, Class<?> presentationType, Class<?> modelType)
converter - The converter to check. If this is null the result is always
false.presentationType - The presentation typemodelType - The model typecanConverterPossiblyHandle(Converter, Class, Class)public static boolean canConverterPossiblyHandle(Converter<?,?> converter, Class<?> presentationType, Class<?> modelType)
converter - The converter to check. If this is null the result is always
false.presentationType - The presentation typemodelType - The model typeCopyright © 2016 Vaadin Ltd. All rights reserved.