DefaultValuesBindHandler Class — spring-boot Architecture
Architecture documentation for the DefaultValuesBindHandler class in ConfigurationPropertiesBindHandlerAdvisorTests.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindHandlerAdvisorTests.java lines 120–155
static class DefaultValuesBindHandler extends AbstractBindHandler {
private final Map<ConfigurationPropertyName, ConfigurationPropertyName> mappings;
DefaultValuesBindHandler(BindHandler bindHandler) {
super(bindHandler);
this.mappings = new LinkedHashMap<>();
this.mappings.put(ConfigurationPropertyName.of("foo.bar.bindings"),
ConfigurationPropertyName.of("foo.bar.default"));
}
@Override
public <T> @Nullable Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target,
BindContext context) {
ConfigurationPropertyName defaultName = getDefaultName(name);
if (defaultName != null) {
BindResult<T> result = context.getBinder().bind(defaultName, target);
if (result.isBound()) {
return target.withExistingValue(result.get());
}
}
return super.onStart(name, target, context);
}
private @Nullable ConfigurationPropertyName getDefaultName(ConfigurationPropertyName name) {
for (Map.Entry<ConfigurationPropertyName, ConfigurationPropertyName> mapping : this.mappings.entrySet()) {
ConfigurationPropertyName from = mapping.getKey();
ConfigurationPropertyName to = mapping.getValue();
if (name.getNumberOfElements() == from.getNumberOfElements() + 1 && from.isParentOf(name)) {
return to;
}
}
return null;
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free