mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-08 09:38:26 +08:00
fix: 修复ClassUtil.doGetMethods最后一个参数为true时,不会提前结束遍历接口
This commit is contained in:
parent
86f4358ebf
commit
9cca7e69cc
@ -288,10 +288,7 @@ public class ClassUtil {
|
|||||||
|
|
||||||
|
|
||||||
private static void doGetMethods(Class<?> clazz, List<Method> methods, Predicate<Method> predicate, boolean firstOnly) {
|
private static void doGetMethods(Class<?> clazz, List<Method> methods, Predicate<Method> predicate, boolean firstOnly) {
|
||||||
if (clazz == null || clazz == Object.class) {
|
applyAllClass(clazz, currentClass -> {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Method[] declaredMethods = clazz.getDeclaredMethods();
|
Method[] declaredMethods = clazz.getDeclaredMethods();
|
||||||
if (clazz.isInterface()) {
|
if (clazz.isInterface()) {
|
||||||
for (Method method : declaredMethods) {
|
for (Method method : declaredMethods) {
|
||||||
@ -313,18 +310,20 @@ public class ClassUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 只获取第一个并且集合不为空就结束遍历
|
||||||
|
|
||||||
if (firstOnly && !methods.isEmpty()) {
|
if (firstOnly && !methods.isEmpty()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class<?>[] interfaces = clazz.getInterfaces();
|
Class<?>[] interfaces = clazz.getInterfaces();
|
||||||
for (Class<?> anInterface : interfaces) {
|
for (Class<?> anInterface : interfaces) {
|
||||||
doGetMethods(anInterface, methods, predicate, firstOnly);
|
doGetMethods(anInterface, methods, predicate, firstOnly);
|
||||||
|
// 只获取第一个并且集合不为空就结束遍历
|
||||||
|
if (firstOnly && !methods.isEmpty()){
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
doGetMethods(clazz.getSuperclass(), methods, predicate, firstOnly);
|
return true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <T> Class<T> getJdkProxySuperClass(Class<T> clazz) {
|
private static <T> Class<T> getJdkProxySuperClass(Class<T> clazz) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user