Polishing
This commit is contained in:
@@ -53,20 +53,21 @@ import org.springframework.expression.spel.SpelMessage;
|
||||
*/
|
||||
public class ReflectiveMethodResolver implements MethodResolver {
|
||||
|
||||
private Map<Class<?>, MethodFilter> filters = null;
|
||||
|
||||
// Using distance will ensure a more accurate match is discovered,
|
||||
// more closely following the Java rules.
|
||||
private boolean useDistance = false;
|
||||
private final boolean useDistance;
|
||||
|
||||
private Map<Class<?>, MethodFilter> filters;
|
||||
|
||||
|
||||
public ReflectiveMethodResolver() {
|
||||
this.useDistance = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This constructors 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). Using the distance computation is intended to ensure matches
|
||||
* are multiple matches). Using the distance computation is intended to ensure matches
|
||||
* are more closely representative of what a Java compiler would do when taking into
|
||||
* account boxing/unboxing and whether the method candidates are declared to handle a
|
||||
* supertype of the type (of the argument) being passed in.
|
||||
@@ -77,6 +78,19 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
}
|
||||
|
||||
|
||||
public void registerMethodFilter(Class<?> type, MethodFilter filter) {
|
||||
if (this.filters == null) {
|
||||
this.filters = new HashMap<Class<?>, MethodFilter>();
|
||||
}
|
||||
if (filter != null) {
|
||||
this.filters.put(type, filter);
|
||||
}
|
||||
else {
|
||||
this.filters.remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Locate a method on a type. There are three kinds of match that might occur:
|
||||
* <ol>
|
||||
@@ -187,18 +201,6 @@ public class ReflectiveMethodResolver implements MethodResolver {
|
||||
}
|
||||
}
|
||||
|
||||
public void registerMethodFilter(Class<?> type, MethodFilter filter) {
|
||||
if (this.filters == null) {
|
||||
this.filters = new HashMap<Class<?>, MethodFilter>();
|
||||
}
|
||||
if (filter == null) {
|
||||
this.filters.remove(type);
|
||||
}
|
||||
else {
|
||||
this.filters.put(type,filter);
|
||||
}
|
||||
}
|
||||
|
||||
private Method[] getMethods(Class<?> type, Object targetObject) {
|
||||
if (targetObject instanceof Class) {
|
||||
Set<Method> methods = new HashSet<Method>();
|
||||
|
||||
Reference in New Issue
Block a user