Use getMethod instead of traversing the inheritance tree

This is possible since property accessors are always public
This commit is contained in:
Ruben Dijkstra 2014-10-04 22:35:41 +02:00
parent 92c30bd8f2
commit d97a447d13

View File

@ -55,15 +55,12 @@ public interface PathBuilderValidator {
@Override
public boolean validate(Class<?> parent, String property, Class<?> propertyType) {
String accessor = "get" + BeanUtils.capitalize(property);
while (!parent.equals(Object.class)) {
try {
parent.getDeclaredMethod(accessor);
return true;
} catch (NoSuchMethodException e) {
parent = parent.getSuperclass();
}
try {
parent.getMethod(accessor);
return true;
} catch (NoSuchMethodException e) {
return false;
}
return false;
}
};