MapConfigurationPropertySource Class — spring-boot Architecture
Architecture documentation for the MapConfigurationPropertySource class in MapConfigurationPropertySource.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java lines 38–114
public class MapConfigurationPropertySource implements IterableConfigurationPropertySource {
private static final PropertyMapper[] DEFAULT_MAPPERS = { DefaultPropertyMapper.INSTANCE };
private final Map<String, Object> source;
private final IterableConfigurationPropertySource delegate;
/**
* Create a new empty {@link MapConfigurationPropertySource} instance.
*/
public MapConfigurationPropertySource() {
this(Collections.emptyMap());
}
/**
* Create a new {@link MapConfigurationPropertySource} instance with entries copies
* from the specified map.
* @param map the source map
*/
public MapConfigurationPropertySource(Map<?, ?> map) {
this.source = new LinkedHashMap<>();
MapPropertySource mapPropertySource = new MapPropertySource("source", this.source);
this.delegate = new SpringIterableConfigurationPropertySource(mapPropertySource, false, DEFAULT_MAPPERS);
putAll(map);
}
/**
* Add all entries from the specified map.
* @param map the source map
*/
public void putAll(Map<?, ?> map) {
Assert.notNull(map, "'map' must not be null");
assertNotReadOnlySystemAttributesMap(map);
map.forEach(this::put);
}
/**
* Add an individual entry.
* @param name the name
* @param value the value
*/
public void put(Object name, Object value) {
Assert.notNull(name, "'name' must not be null");
this.source.put(name.toString(), value);
}
@Override
public Object getUnderlyingSource() {
return this.source;
}
@Override
public @Nullable ConfigurationProperty getConfigurationProperty(ConfigurationPropertyName name) {
return this.delegate.getConfigurationProperty(name);
}
@Override
public Iterator<ConfigurationPropertyName> iterator() {
return this.delegate.iterator();
}
@Override
public Stream<ConfigurationPropertyName> stream() {
return this.delegate.stream();
}
private void assertNotReadOnlySystemAttributesMap(Map<?, ?> map) {
try {
map.size();
}
catch (UnsupportedOperationException ex) {
throw new IllegalArgumentException("Security restricted maps are not supported", ex);
}
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free