public class ReflectiveMethodResolver extends java.lang.Object implements MethodResolver
MethodResolver
used by default in StandardEvaluationContext
unless explicit method resolvers have been specified.StandardEvaluationContext.addMethodResolver(MethodResolver)
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Class<?>,MethodFilter> |
filters |
private boolean |
useDistance |
Constructor and Description |
---|
ReflectiveMethodResolver() |
ReflectiveMethodResolver(boolean useDistance)
This constructor allows the ReflectiveMethodResolver to be configured such that it
will use a distance computation to check which is the better of two close matches
(when there are multiple matches).
|
Modifier and Type | Method and Description |
---|---|
protected java.lang.reflect.Method[] |
getMethods(java.lang.Class<?> type)
Return the set of methods for this type.
|
private java.util.Set<java.lang.reflect.Method> |
getMethods(java.lang.Class<?> type,
java.lang.Object targetObject) |
protected boolean |
isCandidateForInvocation(java.lang.reflect.Method method,
java.lang.Class<?> targetClass)
Determine whether the given
Method is a candidate for method resolution
on an instance of the given target class. |
void |
registerMethodFilter(java.lang.Class<?> type,
MethodFilter filter)
Register a filter for methods on the given type.
|
MethodExecutor |
resolve(EvaluationContext context,
java.lang.Object targetObject,
java.lang.String name,
java.util.List<TypeDescriptor> argumentTypes)
Locate a method on a type.
|
private final boolean useDistance
private java.util.Map<java.lang.Class<?>,MethodFilter> filters
public ReflectiveMethodResolver()
public ReflectiveMethodResolver(boolean useDistance)
useDistance
- true
if distance computation should be used when
calculating matches; false
otherwisepublic void registerMethodFilter(java.lang.Class<?> type, MethodFilter filter)
type
- the type to filter onfilter
- the corresponding method filter,
or null
to clear any filter for the given typepublic MethodExecutor resolve(EvaluationContext context, java.lang.Object targetObject, java.lang.String name, java.util.List<TypeDescriptor> argumentTypes) throws AccessException
resolve
in interface MethodResolver
context
- the current evaluation contexttargetObject
- the object upon which the method is being calledargumentTypes
- the arguments that the constructor must be able to handleAccessException
private java.util.Set<java.lang.reflect.Method> getMethods(java.lang.Class<?> type, java.lang.Object targetObject)
protected java.lang.reflect.Method[] getMethods(java.lang.Class<?> type)
Class.getMethods()
for the given type
, but subclasses
may override in order to alter the results, e.g. specifying static methods
declared elsewhere.type
- the class for which to return the methodsprotected boolean isCandidateForInvocation(java.lang.reflect.Method method, java.lang.Class<?> targetClass)
Method
is a candidate for method resolution
on an instance of the given target class.
The default implementation considers any method as a candidate, even for
static methods sand non-user-declared methods on the Object
base class.
method
- the Method to evaluatetargetClass
- the concrete target class that is being introspected