public abstract class TypeConverterSupport extends PropertyEditorRegistrySupport implements TypeConverter
TypeConverter
interface, using a package-private delegate.
Mainly serves as base class for BeanWrapperImpl
.SimpleTypeConverter
Modifier and Type | Field and Description |
---|---|
(package private) TypeConverterDelegate |
typeConverterDelegate |
Constructor and Description |
---|
TypeConverterSupport() |
Modifier and Type | Method and Description |
---|---|
<T> T |
convertIfNecessary(java.lang.Object value,
java.lang.Class<T> requiredType)
Convert the value to the required type (if necessary from a String).
|
<T> T |
convertIfNecessary(java.lang.Object value,
java.lang.Class<T> requiredType,
java.lang.reflect.Field field)
Convert the value to the required type (if necessary from a String).
|
<T> T |
convertIfNecessary(java.lang.Object value,
java.lang.Class<T> requiredType,
MethodParameter methodParam)
Convert the value to the required type (if necessary from a String).
|
private <T> T |
doConvert(java.lang.Object value,
java.lang.Class<T> requiredType,
MethodParameter methodParam,
java.lang.reflect.Field field) |
copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, getPropertyType, guessPropertyTypeFromEditors, hasCustomEditorForElement, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, setConversionService, useConfigValueEditors
TypeConverterDelegate typeConverterDelegate
public <T> T convertIfNecessary(java.lang.Object value, java.lang.Class<T> requiredType) throws TypeMismatchException
TypeConverter
Conversions from String to any type will typically use the setAsText
method of the PropertyEditor class, or a Spring Converter in a ConversionService.
convertIfNecessary
in interface TypeConverter
value
- the value to convertrequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)TypeMismatchException
- if type conversion failedPropertyEditor.setAsText(String)
,
PropertyEditor.getValue()
,
ConversionService
,
Converter
public <T> T convertIfNecessary(java.lang.Object value, java.lang.Class<T> requiredType, MethodParameter methodParam) throws TypeMismatchException
TypeConverter
Conversions from String to any type will typically use the setAsText
method of the PropertyEditor class, or a Spring Converter in a ConversionService.
convertIfNecessary
in interface TypeConverter
value
- the value to convertrequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)methodParam
- the method parameter that is the target of the conversion
(for analysis of generic types; may be null
)TypeMismatchException
- if type conversion failedPropertyEditor.setAsText(String)
,
PropertyEditor.getValue()
,
ConversionService
,
Converter
public <T> T convertIfNecessary(java.lang.Object value, java.lang.Class<T> requiredType, java.lang.reflect.Field field) throws TypeMismatchException
TypeConverter
Conversions from String to any type will typically use the setAsText
method of the PropertyEditor class, or a Spring Converter in a ConversionService.
convertIfNecessary
in interface TypeConverter
value
- the value to convertrequiredType
- the type we must convert to
(or null
if not known, for example in case of a collection element)field
- the reflective field that is the target of the conversion
(for analysis of generic types; may be null
)TypeMismatchException
- if type conversion failedPropertyEditor.setAsText(String)
,
PropertyEditor.getValue()
,
ConversionService
,
Converter
private <T> T doConvert(java.lang.Object value, java.lang.Class<T> requiredType, MethodParameter methodParam, java.lang.reflect.Field field) throws TypeMismatchException
TypeMismatchException