use of org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler in project incubator-dubbo-spring-boot-project by apache.
the class BinderDubboConfigBinder method getBindHandler.
private BindHandler getBindHandler(boolean ignoreUnknownFields, boolean ignoreInvalidFields) {
BindHandler handler = BindHandler.DEFAULT;
if (ignoreInvalidFields) {
handler = new IgnoreErrorsBindHandler(handler);
}
if (!ignoreUnknownFields) {
UnboundElementsSourceFilter filter = new UnboundElementsSourceFilter();
handler = new NoUnboundElementsBindHandler(handler, filter);
}
return handler;
}
use of org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler in project spring-boot by spring-projects.
the class ConfigurationPropertiesBinder method getBindHandler.
private <T> BindHandler getBindHandler(Bindable<T> target, ConfigurationProperties annotation) {
List<Validator> validators = getValidators(target);
BindHandler handler = getHandler();
handler = new ConfigurationPropertiesBindHandler(handler);
if (annotation.ignoreInvalidFields()) {
handler = new IgnoreErrorsBindHandler(handler);
}
if (!annotation.ignoreUnknownFields()) {
UnboundElementsSourceFilter filter = new UnboundElementsSourceFilter();
handler = new NoUnboundElementsBindHandler(handler, filter);
}
if (!validators.isEmpty()) {
handler = new ValidationBindHandler(handler, validators.toArray(new Validator[0]));
}
for (ConfigurationPropertiesBindHandlerAdvisor advisor : getBindHandlerAdvisors()) {
handler = advisor.apply(handler);
}
return handler;
}
use of org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler in project dubbo by alibaba.
the class BinderDubboConfigBinder method getBindHandler.
private BindHandler getBindHandler(boolean ignoreUnknownFields, boolean ignoreInvalidFields) {
BindHandler handler = BindHandler.DEFAULT;
if (ignoreInvalidFields) {
handler = new IgnoreErrorsBindHandler(handler);
}
if (!ignoreUnknownFields) {
UnboundElementsSourceFilter filter = new UnboundElementsSourceFilter();
handler = new NoUnboundElementsBindHandler(handler, filter);
}
return handler;
}
use of org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler in project spring-boot by spring-projects.
the class JavaBeanBinderTests method bindToClassWhenPropertyCannotBeConvertedAndIgnoreErrorsShouldNotSetValue.
@Test
void bindToClassWhenPropertyCannotBeConvertedAndIgnoreErrorsShouldNotSetValue() {
MockConfigurationPropertySource source = new MockConfigurationPropertySource();
source.put("foo.int-value", "12");
source.put("foo.long-value", "bang");
source.put("foo.string-value", "foo");
source.put("foo.enum-value", "foo-bar");
this.sources.add(source);
IgnoreErrorsBindHandler handler = new IgnoreErrorsBindHandler();
ExampleValueBean bean = this.binder.bind("foo", Bindable.of(ExampleValueBean.class), handler).get();
assertThat(bean.getIntValue()).isEqualTo(12);
assertThat(bean.getLongValue()).isEqualTo(0);
assertThat(bean.getStringValue()).isEqualTo("foo");
assertThat(bean.getEnumValue()).isEqualTo(ExampleEnum.FOO_BAR);
}
Aggregations