Home / Class/ FilteredIterableConfigurationPropertiesSource Class — spring-boot Architecture

FilteredIterableConfigurationPropertiesSource Class — spring-boot Architecture

Architecture documentation for the FilteredIterableConfigurationPropertiesSource class in FilteredIterableConfigurationPropertiesSource.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredIterableConfigurationPropertiesSource.java lines 31–90

class FilteredIterableConfigurationPropertiesSource extends FilteredConfigurationPropertiesSource
		implements IterableConfigurationPropertySource {

	private ConfigurationPropertyName @Nullable [] filteredNames;

	private int numberOfFilteredNames;

	FilteredIterableConfigurationPropertiesSource(IterableConfigurationPropertySource source,
			Predicate<ConfigurationPropertyName> filter) {
		super(source, filter);
		@Nullable ConfigurationPropertyName[] filterableNames = getFilterableNames(source);
		if (filterableNames != null) {
			this.filteredNames = new ConfigurationPropertyName[filterableNames.length];
			this.numberOfFilteredNames = 0;
			for (ConfigurationPropertyName name : filterableNames) {
				if (name == null) {
					break;
				}
				if (filter.test(name)) {
					this.filteredNames[this.numberOfFilteredNames++] = name;
				}
			}
		}
	}

	private @Nullable ConfigurationPropertyName @Nullable [] getFilterableNames(
			IterableConfigurationPropertySource source) {
		if (source instanceof SpringIterableConfigurationPropertySource springPropertySource
				&& springPropertySource.isImmutablePropertySource()) {
			return springPropertySource.getConfigurationPropertyNames();
		}
		if (source instanceof FilteredIterableConfigurationPropertiesSource filteredSource) {
			return filteredSource.filteredNames;
		}
		return null;
	}

	@Override
	public Stream<ConfigurationPropertyName> stream() {
		if (this.filteredNames != null) {
			return Arrays.stream(this.filteredNames, 0, this.numberOfFilteredNames);
		}
		return getSource().stream().filter(getFilter());
	}

	@Override
	protected IterableConfigurationPropertySource getSource() {
		return (IterableConfigurationPropertySource) super.getSource();
	}

	@Override
	public ConfigurationPropertyState containsDescendantOf(ConfigurationPropertyName name) {
		if (this.filteredNames != null) {
			return ConfigurationPropertyState.search(this.filteredNames, 0, this.numberOfFilteredNames,
					name::isAncestorOf);
		}
		return ConfigurationPropertyState.search(this, name::isAncestorOf);
	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free