Skip to content

Commit 47c72ae

Browse files
authored
Merge pull request #2335 from mbond-cloud/mbond-mybatis
Remove redundant call to Reflector#getClassMethods()
2 parents 5e89813 + bd26999 commit 47c72ae

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/main/java/org/apache/ibatis/reflection/Reflector.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ public class Reflector {
6464
public Reflector(Class<?> clazz) {
6565
type = clazz;
6666
addDefaultConstructor(clazz);
67-
addGetMethods(clazz);
68-
addSetMethods(clazz);
67+
Method[] classMethods = getClassMethods(clazz);
68+
addGetMethods(classMethods);
69+
addSetMethods(classMethods);
6970
addFields(clazz);
7071
readablePropertyNames = getMethods.keySet().toArray(new String[0]);
7172
writablePropertyNames = setMethods.keySet().toArray(new String[0]);
@@ -83,9 +84,8 @@ private void addDefaultConstructor(Class<?> clazz) {
8384
.findAny().ifPresent(constructor -> this.defaultConstructor = constructor);
8485
}
8586

86-
private void addGetMethods(Class<?> clazz) {
87+
private void addGetMethods(Method[] methods) {
8788
Map<String, List<Method>> conflictingGetters = new HashMap<>();
88-
Method[] methods = getClassMethods(clazz);
8989
Arrays.stream(methods).filter(m -> m.getParameterTypes().length == 0 && PropertyNamer.isGetter(m.getName()))
9090
.forEach(m -> addMethodConflict(conflictingGetters, PropertyNamer.methodToProperty(m.getName()), m));
9191
resolveGetterConflicts(conflictingGetters);
@@ -134,9 +134,8 @@ private void addGetMethod(String name, Method method, boolean isAmbiguous) {
134134
getTypes.put(name, typeToClass(returnType));
135135
}
136136

137-
private void addSetMethods(Class<?> clazz) {
137+
private void addSetMethods(Method[] methods) {
138138
Map<String, List<Method>> conflictingSetters = new HashMap<>();
139-
Method[] methods = getClassMethods(clazz);
140139
Arrays.stream(methods).filter(m -> m.getParameterTypes().length == 1 && PropertyNamer.isSetter(m.getName()))
141140
.forEach(m -> addMethodConflict(conflictingSetters, PropertyNamer.methodToProperty(m.getName()), m));
142141
resolveSetterConflicts(conflictingSetters);

0 commit comments

Comments
 (0)