use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class ConfigurationPropertiesReportEndpoint method applyInput.
private Map<String, Object> applyInput(String qualifiedKey) {
ConfigurationPropertyName currentName = getCurrentName(qualifiedKey);
ConfigurationProperty candidate = getCandidate(currentName);
PropertySource<?> propertySource = getPropertySource(candidate);
if (propertySource != null) {
Object value = stringifyIfNecessary(candidate.getValue());
SanitizableData data = new SanitizableData(propertySource, currentName.toString(), value);
return getInput(candidate, this.sanitizer.sanitize(data));
}
return Collections.emptyMap();
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class ValidationErrorsTests method getErrorsShouldAdaptFieldErrorsToBeOriginProviders.
@Test
void getErrorsShouldAdaptFieldErrorsToBeOriginProviders() {
Set<ConfigurationProperty> boundProperties = new LinkedHashSet<>();
ConfigurationPropertyName name1 = ConfigurationPropertyName.of("foo.bar");
Origin origin1 = MockOrigin.of("line1");
boundProperties.add(new ConfigurationProperty(name1, "boot", origin1));
ConfigurationPropertyName name2 = ConfigurationPropertyName.of("foo.baz.bar");
Origin origin2 = MockOrigin.of("line2");
boundProperties.add(new ConfigurationProperty(name2, "boot", origin2));
List<ObjectError> allErrors = new ArrayList<>();
allErrors.add(new FieldError("objectname", "bar", "message"));
ValidationErrors errors = new ValidationErrors(ConfigurationPropertyName.of("foo.baz"), boundProperties, allErrors);
assertThat(Origin.from(errors.getAllErrors().get(0))).isEqualTo(origin2);
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class IndexedElementsBinder method getKnownIndexedChildren.
private MultiValueMap<String, ConfigurationPropertyName> getKnownIndexedChildren(ConfigurationPropertySource source, ConfigurationPropertyName root) {
MultiValueMap<String, ConfigurationPropertyName> children = new LinkedMultiValueMap<>();
if (!(source instanceof IterableConfigurationPropertySource)) {
return children;
}
for (ConfigurationPropertyName name : (IterableConfigurationPropertySource) source.filter(root::isAncestorOf)) {
ConfigurationPropertyName choppedName = name.chop(root.getNumberOfElements() + 1);
if (choppedName.isLastElementIndexed()) {
String key = choppedName.getLastElement(Form.UNIFORM);
children.add(key, name);
}
}
return children;
}
use of org.springframework.boot.context.properties.source.ConfigurationPropertyName in project spring-boot by spring-projects.
the class NoUnboundElementsBindHandler method isOverriddenCollectionElement.
private boolean isOverriddenCollectionElement(ConfigurationPropertyName candidate) {
int lastIndex = candidate.getNumberOfElements() - 1;
if (candidate.isLastElementIndexed()) {
ConfigurationPropertyName propertyName = candidate.chop(lastIndex);
return this.boundNames.contains(propertyName);
}
Indexed indexed = getIndexed(candidate);
if (indexed != null) {
String zeroethProperty = indexed.getName() + "[0]";
if (this.boundNames.contains(ConfigurationPropertyName.of(zeroethProperty))) {
String nestedZeroethProperty = zeroethProperty + "." + indexed.getNestedPropertyName();
return isCandidateValidPropertyName(nestedZeroethProperty);
}
}
return false;
}
Aggregations