Class ReflectionHelper
- Since:
 - 3.0
 - Author:
 - Andy Clement, Juergen Hoeller, Sam Brannen
 
- 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionstatic booleanconvertAllArguments(TypeConverter converter, Object[] arguments, Method method) Convert the supplied set of arguments into the parameter types of the suppliedMethod.static booleanconvertAllMethodHandleArguments(TypeConverter converter, Object[] arguments, MethodHandle methodHandle, Integer varargsPosition) Convert the supplied set of arguments into the parameter types of the suppliedMethodHandle, taking the varargs position into account.static intgetTypeDifferenceWeight(List<TypeDescriptor> paramTypes, List<TypeDescriptor> argTypes) Based onMethodInvoker.getTypeDifferenceWeight(Class[], Object[])but operates on TypeDescriptors.static Object[]setupArgumentsForVarargsInvocation(Class<?>[] requiredParameterTypes, Object... args) Package up the suppliedargsso that they correctly match what is expected inrequiredParameterTypes. 
- 
Constructor Details
- 
ReflectionHelper
public ReflectionHelper() 
 - 
 - 
Method Details
- 
getTypeDifferenceWeight
public static int getTypeDifferenceWeight(List<TypeDescriptor> paramTypes, List<TypeDescriptor> argTypes) Based onMethodInvoker.getTypeDifferenceWeight(Class[], Object[])but operates on TypeDescriptors. - 
convertAllArguments
public static boolean convertAllArguments(TypeConverter converter, Object[] arguments, Method method) throws SpelEvaluationException Convert the supplied set of arguments into the parameter types of the suppliedMethod.If the supplied method is a varargs method, the final parameter type must be an array whose component type should be used as the conversion target for extraneous arguments. For example, if the parameter types are
{Integer, String[]}and the input arguments are{Integer, boolean, float}, then both thebooleanand thefloatmust be converted to strings.This method does not repackage the arguments into a form suitable for the varargs invocation: a subsequent call to
setupArgumentsForVarargsInvocation(Class[], Object...)is required for that.- Parameters:
 converter- the converter to use for type conversionsarguments- the arguments to convert to the required parameter typesmethod- the targetMethod- Returns:
 trueif some kind of conversion occurred on an argument- Throws:
 SpelEvaluationException- if a problem occurs during conversion
 - 
convertAllMethodHandleArguments
public static boolean convertAllMethodHandleArguments(TypeConverter converter, Object[] arguments, MethodHandle methodHandle, @Nullable Integer varargsPosition) throws EvaluationException Convert the supplied set of arguments into the parameter types of the suppliedMethodHandle, taking the varargs position into account.The arguments are converted 'in-place' in the input array.
- Parameters:
 converter- the converter to use for type conversionsarguments- the arguments to convert to the required parameter typesmethodHandle- the targetMethodHandlevarargsPosition- the known position of the varargs argument, if any (nullif not varargs)- Returns:
 trueif some kind of conversion occurred on an argument- Throws:
 EvaluationException- if a problem occurs during conversion- Since:
 - 6.1
 
 - 
setupArgumentsForVarargsInvocation
public static Object[] setupArgumentsForVarargsInvocation(Class<?>[] requiredParameterTypes, Object... args) Package up the suppliedargsso that they correctly match what is expected inrequiredParameterTypes.For example, if
requiredParameterTypesis(int, String[])because the second parameter was declared asString..., then ifargsis[1, "a", "b"]it must be repackaged as[1, new String[] {"a", "b"}]in order to match the expected types.- Parameters:
 requiredParameterTypes- the types of the parameters for the invocationargs- the arguments to be set up for the invocation- Returns:
 - a repackaged array of arguments where any varargs setup has been performed
 
 
 -