use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpoint method sanitizeWithPropertySourceIfPresent.
private Object sanitizeWithPropertySourceIfPresent(String qualifiedKey, Object value) {
ConfigurationPropertyName currentName = getCurrentName(qualifiedKey);
ConfigurationProperty candidate = getCandidate(currentName);
PropertySource<?> propertySource = getPropertySource(candidate);
if (propertySource != null) {
SanitizableData data = new SanitizableData(propertySource, qualifiedKey, value);
return this.sanitizer.sanitize(data);
}
SanitizableData data = new SanitizableData(null, qualifiedKey, value);
return this.sanitizer.sanitize(data);
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class IndexedElementsBinder method bindIndexed.
private void bindIndexed(ConfigurationPropertySource source, ConfigurationPropertyName root, AggregateElementBinder elementBinder, IndexedCollectionSupplier collection, ResolvableType elementType) {
MultiValueMap<String, ConfigurationPropertyName> knownIndexedChildren = getKnownIndexedChildren(source, root);
for (int i = 0; i < Integer.MAX_VALUE; i++) {
ConfigurationPropertyName name = root.append((i != 0) ? "[" + i + "]" : INDEX_ZERO);
Object value = elementBinder.bind(name, Bindable.of(elementType), source);
if (value == null) {
break;
}
knownIndexedChildren.remove(name.getLastElement(Form.UNIFORM));
collection.get().add(value);
}
assertNoUnboundChildren(source, knownIndexedChildren);
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class ConfigDataEnvironmentPostProcessorIntegrationTests method runWhenImportingIncludesParentOrigin.
@Test
void runWhenImportingIncludesParentOrigin() {
ConfigurableApplicationContext context = this.application.run("--spring.config.location=classpath:application-import-with-placeholder.properties");
Binder binder = Binder.get(context.getEnvironment());
List<ConfigurationProperty> properties = new ArrayList<>();
BindHandler bindHandler = new BindHandler() {
@Override
public Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Object result) {
properties.add(context.getConfigurationProperty());
return result;
}
};
binder.bind("my.value", Bindable.of(String.class), bindHandler);
assertThat(properties).hasSize(1);
Origin origin = properties.get(0).getOrigin();
assertThat(origin.toString()).contains("application-import-with-placeholder-imported");
assertThat(origin.getParent().toString()).contains("application-import-with-placeholder");
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class BinderTests method bindToJavaBeanWhenHandlerOnStartReturnsNullShouldReturnUnbound.
@Test
void bindToJavaBeanWhenHandlerOnStartReturnsNullShouldReturnUnbound() {
// gh-18129
this.sources.add(new MockConfigurationPropertySource("foo.value", "bar"));
BindResult<JavaBean> result = this.binder.bind("foo", Bindable.of(JavaBean.class), new BindHandler() {
@Override
public <T> Bindable<T> onStart(ConfigurationPropertyName name, Bindable<T> target, BindContext context) {
return null;
}
});
assertThat(result.isBound()).isFalse();
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class ValidationErrorsTests method getNameShouldReturnName.
@Test
void getNameShouldReturnName() {
ConfigurationPropertyName name = NAME;
ValidationErrors errors = new ValidationErrors(name, Collections.emptySet(), Collections.emptyList());
assertThat((Object) errors.getName()).isEqualTo(name);
}
Aggregations