public class ReflectionHelper
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
(package private) static class |
ReflectionHelper.ArgumentsMatchInfo
An instance of ArgumentsMatchInfo describes what kind of match was achieved
between two sets of arguments - the set that a method/constructor is expecting
and the set that are being supplied at the point of invocation.
|
(package private) static class |
ReflectionHelper.ArgumentsMatchKind |
| Constructor and Description |
|---|
ReflectionHelper() |
| Modifier and Type | Method and Description |
|---|---|
(package private) static ReflectionHelper.ArgumentsMatchInfo |
compareArguments(java.util.List<TypeDescriptor> expectedArgTypes,
java.util.List<TypeDescriptor> suppliedArgTypes,
TypeConverter typeConverter)
Compare argument arrays and return information about whether they match.
|
(package private) static ReflectionHelper.ArgumentsMatchInfo |
compareArgumentsVarargs(java.util.List<TypeDescriptor> expectedArgTypes,
java.util.List<TypeDescriptor> suppliedArgTypes,
TypeConverter typeConverter)
Compare argument arrays and return information about whether they match.
|
static boolean |
convertAllArguments(TypeConverter converter,
java.lang.Object[] arguments,
java.lang.reflect.Method method)
Convert a supplied set of arguments into the requested types.
|
(package private) static boolean |
convertArguments(TypeConverter converter,
java.lang.Object[] arguments,
java.lang.Object methodOrCtor,
java.lang.Integer varargsPosition)
Takes an input set of argument values and converts them to the types specified as the
required parameter types.
|
static int |
getTypeDifferenceWeight(java.util.List<TypeDescriptor> paramTypes,
java.util.List<TypeDescriptor> argTypes)
Based on
MethodInvoker.getTypeDifferenceWeight(Class[], Object[]) but operates on TypeDescriptors. |
private static boolean |
isFirstEntryInArray(java.lang.Object value,
java.lang.Object possibleArray)
Check if the supplied value is the first entry in the array represented by the possibleArray value.
|
static java.lang.Object[] |
setupArgumentsForVarargsInvocation(java.lang.Class<?>[] requiredParameterTypes,
java.lang.Object... args)
Package up the arguments so that they correctly match what is expected in parameterTypes.
|
static ReflectionHelper.ArgumentsMatchInfo compareArguments(java.util.List<TypeDescriptor> expectedArgTypes, java.util.List<TypeDescriptor> suppliedArgTypes, TypeConverter typeConverter)
expectedArgTypes - the types the method/constructor is expectingsuppliedArgTypes - the types that are being supplied at the point of invocationtypeConverter - a registered type converternull if it was not a matchpublic static int getTypeDifferenceWeight(java.util.List<TypeDescriptor> paramTypes, java.util.List<TypeDescriptor> argTypes)
MethodInvoker.getTypeDifferenceWeight(Class[], Object[]) but operates on TypeDescriptors.static ReflectionHelper.ArgumentsMatchInfo compareArgumentsVarargs(java.util.List<TypeDescriptor> expectedArgTypes, java.util.List<TypeDescriptor> suppliedArgTypes, TypeConverter typeConverter)
expectedArgTypes - the types the method/constructor is expectingsuppliedArgTypes - the types that are being supplied at the point of invocationtypeConverter - a registered type converternull if it was not a matchpublic static boolean convertAllArguments(TypeConverter converter, java.lang.Object[] arguments, java.lang.reflect.Method method) throws SpelEvaluationException
converter - the converter to use for type conversionsarguments - the arguments to convert to the requested parameter typesmethod - the target MethodSpelEvaluationException - if there is a problem with conversionstatic boolean convertArguments(TypeConverter converter, java.lang.Object[] arguments, java.lang.Object methodOrCtor, java.lang.Integer varargsPosition) throws EvaluationException
converter - the type converter to use for attempting conversionsarguments - the actual arguments that need conversionmethodOrCtor - the target Method or ConstructorvarargsPosition - the known position of the varargs argument, if any
(null if not varargs)true if some kind of conversion occurred on an argumentEvaluationException - if a problem occurs during conversionprivate static boolean isFirstEntryInArray(java.lang.Object value,
java.lang.Object possibleArray)
value - the value to check for in the arraypossibleArray - an array object that may have the supplied value as the first elementpublic static java.lang.Object[] setupArgumentsForVarargsInvocation(java.lang.Class<?>[] requiredParameterTypes,
java.lang.Object... args)
(int, String[]) because the second parameter
was declared String..., then if arguments is [1,"a","b"] then it must be
repackaged as [1,new String[]{"a","b"}] in order to match the expected types.requiredParameterTypes - the types of the parameters for the invocationargs - the arguments to be setup ready for the invocation