public class ArgumentConvertingMethodInvoker extends MethodInvoker
MethodInvoker
that tries to convert the given
arguments for the actual target method via a TypeConverter
.
Supports flexible argument conversions, in particular for invoking a specific overloaded method.
AbstractNestablePropertyAccessor.convertIfNecessary(java.lang.String, java.lang.Object, java.lang.Object, java.lang.Class<?>, org.springframework.core.convert.TypeDescriptor)
targetClass
Constructor and Description |
---|
ArgumentConvertingMethodInvoker() |
Modifier and Type | Method and Description |
---|---|
protected java.lang.reflect.Method |
doFindMatchingMethod(java.lang.Object[] arguments)
Actually find a method with matching parameter type, i.e.
|
protected java.lang.reflect.Method |
findMatchingMethod()
This implementation looks for a method with matching parameter types.
|
protected TypeConverter |
getDefaultTypeConverter()
Obtain the default TypeConverter for this method invoker.
|
TypeConverter |
getTypeConverter()
Return the TypeConverter used for argument type conversion.
|
void |
registerCustomEditor(java.lang.Class<?> requiredType,
java.beans.PropertyEditor propertyEditor)
Register the given custom property editor for all properties of the given type.
|
void |
setTypeConverter(TypeConverter typeConverter)
Set a TypeConverter to use for argument type conversion.
|
getArguments, getPreparedMethod, getTargetClass, getTargetMethod, getTargetObject, getTypeDifferenceWeight, invoke, isPrepared, prepare, resolveClassName, setArguments, setStaticMethod, setTargetClass, setTargetMethod, setTargetObject
public void setTypeConverter(@Nullable TypeConverter typeConverter)
Default is a SimpleTypeConverter
.
Can be overridden with any TypeConverter implementation, typically
a pre-configured SimpleTypeConverter or a BeanWrapperImpl instance.
SimpleTypeConverter
,
BeanWrapperImpl
@Nullable public TypeConverter getTypeConverter()
Can be cast to PropertyEditorRegistry
if direct access to the underlying PropertyEditors is desired
(provided that the present TypeConverter actually implements the
PropertyEditorRegistry interface).
protected TypeConverter getDefaultTypeConverter()
Called if no explicit TypeConverter has been specified.
The default implementation builds a
SimpleTypeConverter
.
Can be overridden in subclasses.
public void registerCustomEditor(java.lang.Class<?> requiredType, java.beans.PropertyEditor propertyEditor)
Typically used in conjunction with the default
SimpleTypeConverter
; will work with any
TypeConverter that implements the PropertyEditorRegistry interface as well.
requiredType
- type of the propertypropertyEditor
- editor to registersetTypeConverter(org.springframework.beans.TypeConverter)
,
PropertyEditorRegistry.registerCustomEditor(java.lang.Class<?>, java.beans.PropertyEditor)
protected java.lang.reflect.Method findMatchingMethod()
findMatchingMethod
in class MethodInvoker
null
if nonedoFindMatchingMethod(java.lang.Object[])
@Nullable protected java.lang.reflect.Method doFindMatchingMethod(java.lang.Object[] arguments)
arguments
- the argument values to match against method parametersnull
if none