Extract duplicated code into a separate method
This commit is contained in:
parent
92053bb84e
commit
d2bfca7900
|
|
@ -1120,13 +1120,7 @@ public abstract class ClassUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<Method> candidates = new HashSet<>(1);
|
Set<Method> candidates = findMethodCandidatesByName(clazz, methodName);
|
||||||
Method[] methods = clazz.getMethods();
|
|
||||||
for (Method method : methods) {
|
|
||||||
if (methodName.equals(method.getName())) {
|
|
||||||
candidates.add(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (candidates.size() == 1) {
|
if (candidates.size() == 1) {
|
||||||
return candidates.iterator().next();
|
return candidates.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
@ -1165,13 +1159,7 @@ public abstract class ClassUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Set<Method> candidates = new HashSet<>(1);
|
Set<Method> candidates = findMethodCandidatesByName(clazz, methodName);
|
||||||
Method[] methods = clazz.getMethods();
|
|
||||||
for (Method method : methods) {
|
|
||||||
if (methodName.equals(method.getName())) {
|
|
||||||
candidates.add(method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (candidates.size() == 1) {
|
if (candidates.size() == 1) {
|
||||||
return candidates.iterator().next();
|
return candidates.iterator().next();
|
||||||
}
|
}
|
||||||
|
|
@ -1362,4 +1350,14 @@ public abstract class ClassUtils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Set<Method> findMethodCandidatesByName(Class<?> clazz, String methodName) {
|
||||||
|
Set<Method> candidates = new HashSet<>(1);
|
||||||
|
Method[] methods = clazz.getMethods();
|
||||||
|
for (Method method : methods) {
|
||||||
|
if (methodName.equals(method.getName())) {
|
||||||
|
candidates.add(method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return candidates;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue