SourcesIterator Class — spring-boot Architecture
Architecture documentation for the SourcesIterator class in SpringConfigurationPropertySources.java from the spring-boot codebase.
Entity Profile
Relationship Graph
Source Code
core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySources.java lines 79–140
private static class SourcesIterator implements Iterator<ConfigurationPropertySource> {
private final Deque<Iterator<PropertySource<?>>> iterators;
private @Nullable ConfigurationPropertySource next;
private final Function<PropertySource<?>, ConfigurationPropertySource> adapter;
SourcesIterator(Iterator<PropertySource<?>> iterator,
Function<PropertySource<?>, ConfigurationPropertySource> adapter) {
this.iterators = new ArrayDeque<>(4);
this.iterators.push(iterator);
this.adapter = adapter;
}
@Override
public boolean hasNext() {
return fetchNext() != null;
}
@Override
public ConfigurationPropertySource next() {
ConfigurationPropertySource next = fetchNext();
if (next == null) {
throw new NoSuchElementException();
}
this.next = null;
return next;
}
private @Nullable ConfigurationPropertySource fetchNext() {
if (this.next == null) {
if (this.iterators.isEmpty()) {
return null;
}
if (!this.iterators.peek().hasNext()) {
this.iterators.pop();
return fetchNext();
}
PropertySource<?> candidate = this.iterators.peek().next();
if (candidate.getSource() instanceof ConfigurableEnvironment configurableEnvironment) {
push(configurableEnvironment);
return fetchNext();
}
if (isIgnored(candidate)) {
return fetchNext();
}
this.next = this.adapter.apply(candidate);
}
return this.next;
}
private void push(ConfigurableEnvironment environment) {
this.iterators.push(environment.getPropertySources().iterator());
}
private boolean isIgnored(PropertySource<?> candidate) {
return (candidate instanceof StubPropertySource
|| candidate instanceof ConfigurationPropertySourcesPropertySource);
}
}
Domain
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free