commit
b3a304fbe7
|
@ -165,7 +165,8 @@ class JavaBeanBinder implements DataObjectBinder {
|
||||||
private boolean isCandidate(Method method) {
|
private boolean isCandidate(Method method) {
|
||||||
int modifiers = method.getModifiers();
|
int modifiers = method.getModifiers();
|
||||||
return !Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isAbstract(modifiers)
|
return !Modifier.isPrivate(modifiers) && !Modifier.isProtected(modifiers) && !Modifier.isAbstract(modifiers)
|
||||||
&& !Modifier.isStatic(modifiers) && !Object.class.equals(method.getDeclaringClass())
|
&& !Modifier.isStatic(modifiers) && !method.isBridge()
|
||||||
|
&& !Object.class.equals(method.getDeclaringClass())
|
||||||
&& !Class.class.equals(method.getDeclaringClass()) && method.getName().indexOf('$') == -1;
|
&& !Class.class.equals(method.getDeclaringClass()) && method.getName().indexOf('$') == -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -318,6 +318,18 @@ class JavaBeanBinderTests {
|
||||||
assertThat(bean.getValueBean()).isNull();
|
assertThat(bean.getValueBean()).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void bindToClassWithOverriddenPropertyShouldSetSubclassProperty() {
|
||||||
|
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
||||||
|
source.put("foo.value-bean.int-value", "123");
|
||||||
|
source.put("foo.value-bean.sub-int-value", "456");
|
||||||
|
this.sources.add(source);
|
||||||
|
ExampleNestedSubclassBean bean = this.binder.bind("foo", Bindable.of(ExampleNestedSubclassBean.class)).get();
|
||||||
|
assertThat(bean.getValueBean()).isNotNull();
|
||||||
|
assertThat(bean.getValueBean().getIntValue()).isEqualTo(123);
|
||||||
|
assertThat(bean.getValueBean().getSubIntValue()).isEqualTo(456);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void bindToClassWhenPropertiesMissingShouldReturnUnbound() {
|
void bindToClassWhenPropertiesMissingShouldReturnUnbound() {
|
||||||
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
|
||||||
|
@ -804,6 +816,35 @@ class JavaBeanBinderTests {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class ExampleNestedSubclassBean extends ExampleNestedBean {
|
||||||
|
|
||||||
|
private ExampleValueSubclassBean valueBean;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
ExampleValueSubclassBean getValueBean() {
|
||||||
|
return this.valueBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setValueBean(ExampleValueSubclassBean valueBean) {
|
||||||
|
this.valueBean = valueBean;
|
||||||
|
}
|
||||||
|
|
||||||
|
static class ExampleValueSubclassBean extends ExampleValueBean {
|
||||||
|
|
||||||
|
private int subIntValue;
|
||||||
|
|
||||||
|
int getSubIntValue() {
|
||||||
|
return this.subIntValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setSubIntValue(int intValue) {
|
||||||
|
this.subIntValue = intValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static class ExampleWithNonDefaultConstructor {
|
static class ExampleWithNonDefaultConstructor {
|
||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
Loading…
Reference in New Issue