Home / Class/ ConfigDataLocationBindHandler Class — spring-boot Architecture

ConfigDataLocationBindHandler Class — spring-boot Architecture

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

Entity Profile

Relationship Graph

Source Code

core/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigDataLocationBindHandler.java lines 41–75

class ConfigDataLocationBindHandler extends AbstractBindHandler {

	@Override
	public @Nullable Object onSuccess(ConfigurationPropertyName name, Bindable<?> target, BindContext context,
			Object result) {
		OriginMapper originMapper = new OriginMapper(context.getConfigurationProperty());
		if (result instanceof ConfigDataLocation location) {
			return originMapper.map(location);
		}
		if (result instanceof List<?> locations) {
			return locations.stream().map(originMapper::mapIfPossible).collect(Collectors.toCollection(ArrayList::new));
		}
		if (result instanceof ConfigDataLocation[] locations) {
			return Arrays.stream(locations).map(originMapper::mapIfPossible).toArray(ConfigDataLocation[]::new);
		}
		return result;
	}

	private record OriginMapper(@Nullable ConfigurationProperty property) {

		@Nullable Object mapIfPossible(@Nullable Object object) {
			return (object instanceof ConfigDataLocation location) ? map(location) : object;
		}

		@Nullable ConfigDataLocation map(@Nullable ConfigDataLocation location) {
			if (location == null) {
				return null;
			}
			Origin origin = Origin.from(location);
			return (origin != null) ? location : location.withOrigin(Origin.from(property()));
		}

	}

}

Domain

Analyze Your Own Codebase

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

Try Supermodel Free