Merge branch '3.2.x' into master
* 3.2.x: Exclude spring-build-src from maven publish Move spring-build-junit into spring-core Relocate MergePlugin package Develop a gradle plugin to add test dependencies Expose Gradle buildSrc for IDE support Fix [deprecation] compiler warnings Upgrade to xmlunit version 1.3 Improve 'build' folder ignores Fix regression in static setter method support Fix SpEL JavaBean compliance for setters Conflicts: spring-beans/src/test/java/org/springframework/beans/ExtendedBeanInfoTests.java
This commit is contained in:
@@ -311,15 +311,10 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
*/
|
||||
protected Method findGetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic) {
|
||||
Method[] ms = clazz.getMethods();
|
||||
String propertyWriteMethodSuffix;
|
||||
if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
|
||||
propertyWriteMethodSuffix = propertyName;
|
||||
}
|
||||
else {
|
||||
propertyWriteMethodSuffix = StringUtils.capitalize(propertyName);
|
||||
}
|
||||
String propertyMethodSuffix = getPropertyMethodSuffix(propertyName);
|
||||
|
||||
// Try "get*" method...
|
||||
String getterName = "get" + propertyWriteMethodSuffix;
|
||||
String getterName = "get" + propertyMethodSuffix;
|
||||
for (Method method : ms) {
|
||||
if (!method.isBridge() && method.getName().equals(getterName) && method.getParameterTypes().length == 0 &&
|
||||
(!mustBeStatic || Modifier.isStatic(method.getModifiers()))) {
|
||||
@@ -327,7 +322,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
}
|
||||
}
|
||||
// Try "is*" method...
|
||||
getterName = "is" + propertyWriteMethodSuffix;
|
||||
getterName = "is" + propertyMethodSuffix;
|
||||
for (Method method : ms) {
|
||||
if (!method.isBridge() && method.getName().equals(getterName) && method.getParameterTypes().length == 0 &&
|
||||
(boolean.class.equals(method.getReturnType()) || Boolean.class.equals(method.getReturnType())) &&
|
||||
@@ -343,7 +338,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
*/
|
||||
protected Method findSetterForProperty(String propertyName, Class<?> clazz, boolean mustBeStatic) {
|
||||
Method[] methods = clazz.getMethods();
|
||||
String setterName = "set" + StringUtils.capitalize(propertyName);
|
||||
String setterName = "set" + getPropertyMethodSuffix(propertyName);
|
||||
for (Method method : methods) {
|
||||
if (!method.isBridge() && method.getName().equals(setterName) && method.getParameterTypes().length == 1 &&
|
||||
(!mustBeStatic || Modifier.isStatic(method.getModifiers()))) {
|
||||
@@ -353,6 +348,15 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected String getPropertyMethodSuffix(String propertyName) {
|
||||
if (propertyName.length() > 1 && Character.isUpperCase(propertyName.charAt(1))) {
|
||||
return propertyName;
|
||||
}
|
||||
else {
|
||||
return StringUtils.capitalize(propertyName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a field of a certain name on a specified class
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user