com.vaadin.ui.declarative.converters.
Class DesignToStringConverter<TYPE>
- java.lang.Object
-
- com.vaadin.ui.declarative.converters.DesignToStringConverter<TYPE>
-
Type Parameters:
TYPE
- Type of the data being converted.All Implemented Interfaces:
Converter<String,TYPE>
,Serializable
public class DesignToStringConverter<TYPE> extends Object implements Converter<String,TYPE>
Utility class for
DesignAttributeHandler
that deals with converting various types to string.Since:
7.4
Author:
Vaadin Ltd
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.data.util.converter.Converter
Converter.ConversionException
-
-
Field Summary
Fields Modifier and Type Field Description static String
NULL_VALUE_REPRESENTATION
A string that corresponds to how a null value is stored.
-
Constructor Summary
Constructors Constructor Description DesignToStringConverter(Class<? extends TYPE> type)
Constructs the converter for a given type.
DesignToStringConverter(Class<? extends TYPE> type, String staticMethodName)
Constructs the converter for a given type, giving the name of the public static method that does the conversion from String.
-
Method Summary
All Methods Modifier and Type Method Description TYPE
convertToModel(String value, Class<? extends TYPE> targetType, Locale locale)
Converts the given value from target type to source type.
String
convertToPresentation(TYPE value, Class<? extends String> targetType, Locale locale)
Converts the given value from source type to target type.
Class<TYPE>
getModelType()
The source type of the converter.
Class<String>
getPresentationType()
The target type of the converter.
-
-
-
Field Detail
-
NULL_VALUE_REPRESENTATION
public static final String NULL_VALUE_REPRESENTATION
A string that corresponds to how a null value is stored.
See Also:
-
-
Constructor Detail
-
DesignToStringConverter
public DesignToStringConverter(Class<? extends TYPE> type)
Constructs the converter for a given type. Implicitly requires that a static method
valueOf(String)
is present in the type to do the conversion.Parameters:
type
- Type of values to convert.
-
DesignToStringConverter
public DesignToStringConverter(Class<? extends TYPE> type, String staticMethodName)
Constructs the converter for a given type, giving the name of the public static method that does the conversion from String.
Parameters:
type
- Type to convert.staticMethodName
- Method to call when converting from String to this type. This must be public and static method that returns an object of passed type.
-
-
Method Detail
-
convertToModel
public TYPE convertToModel(String value, Class<? extends TYPE> targetType, Locale locale) throws Converter.ConversionException
Description copied from interface:
Converter
Converts the given value from target type to source type.
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
andConverter.convertToModel(Object, Class, Locale)
should return the original value.Specified by:
convertToModel
in interfaceConverter<String,TYPE>
Parameters:
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.Returns:
The converted value compatible with the source type
Throws:
Converter.ConversionException
- If the value could not be converted
-
convertToPresentation
public String convertToPresentation(TYPE value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException
Description copied from interface:
Converter
Converts the given value from source type to target type.
A converter can optionally use locale to do the conversion.
A converter should in most cases be symmetric so chainingConverter.convertToPresentation(Object, Class, Locale)
andConverter.convertToModel(Object, Class, Locale)
should return the original value.Specified by:
convertToPresentation
in interfaceConverter<String,TYPE>
Parameters:
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.Returns:
The converted value compatible with the source type
Throws:
Converter.ConversionException
- If the value could not be converted
-
getModelType
public Class<TYPE> getModelType()
Description copied from interface:
Converter
The source type of the converter. Values of this type can be passed to
Converter.convertToPresentation(Object, Class, Locale)
.Specified by:
getModelType
in interfaceConverter<String,TYPE>
Returns:
The source type
-
getPresentationType
public Class<String> getPresentationType()
Description copied from interface:
Converter
The target type of the converter. Values of this type can be passed to
Converter.convertToModel(Object, Class, Locale)
.Specified by:
getPresentationType
in interfaceConverter<String,TYPE>
Returns:
The target type
-
-