Skip to content

Commit

Permalink
Merge pull request #2335 from mbond-cloud/mbond-mybatis
Browse files Browse the repository at this point in the history
Remove redundant call to Reflector#getClassMethods()
  • Loading branch information
harawata committed Sep 7, 2021
2 parents 5e89813 + bd26999 commit 47c72ae
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/org/apache/ibatis/reflection/Reflector.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,9 @@ public class Reflector {
public Reflector(Class<?> clazz) {
type = clazz;
addDefaultConstructor(clazz);
addGetMethods(clazz);
addSetMethods(clazz);
Method[] classMethods = getClassMethods(clazz);
addGetMethods(classMethods);
addSetMethods(classMethods);
addFields(clazz);
readablePropertyNames = getMethods.keySet().toArray(new String[0]);
writablePropertyNames = setMethods.keySet().toArray(new String[0]);
Expand All @@ -83,9 +84,8 @@ private void addDefaultConstructor(Class<?> clazz) {
.findAny().ifPresent(constructor -> this.defaultConstructor = constructor);
}

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

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

0 comments on commit 47c72ae

Please sign in to comment.