public class SimpleTypeConverter extends PropertyEditorRegistrySupport implements TypeConverter
BeanWrapperImpl
Modifier and Type | Field and Description |
---|---|
private TypeConverterDelegate |
typeConverterDelegate |
Constructor and Description |
---|
SimpleTypeConverter() |
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,
MethodParameter methodParam)
Convert the value to the required type (if necessary from a String).
|
copyCustomEditorsTo, copyDefaultEditorsTo, findCustomEditor, getConversionService, getDefaultEditor, getPropertyType, guessPropertyTypeFromEditors, hasCustomEditorForElement, isSharedEditor, overrideDefaultEditor, registerCustomEditor, registerCustomEditor, registerDefaultEditors, registerSharedEditor, setConversionService, useConfigValueEditors
private final 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. Note that a PropertyEditor must be registered
for the given class for this to work; this is a standard JavaBeans API.
A number of PropertyEditors are automatically registered.
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()
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. Note that a PropertyEditor must be registered
for the given class for this to work; this is a standard JavaBeans API.
A number of PropertyEditors are automatically registered.
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()