Home / Class/ DockerEnv Class — spring-boot Architecture

DockerEnv Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/DockerEnv.java lines 35–78

class DockerEnv {

	private final Map<String, @Nullable String> map;

	/**
	 * Create a new {@link DockerEnv} instance.
	 * @param env a list of env entries in the form {@code name=value} or {@code name}.
	 */
	DockerEnv(@Nullable List<String> env) {
		this.map = parse(env);
	}

	private Map<String, @Nullable String> parse(@Nullable List<String> env) {
		if (CollectionUtils.isEmpty(env)) {
			return Collections.emptyMap();
		}
		Map<String, @Nullable String> result = new LinkedHashMap<>();
		env.stream().map(this::parseEntry).forEach((entry) -> result.put(entry.key(), entry.value()));
		return Collections.unmodifiableMap(result);
	}

	private Entry parseEntry(String entry) {
		int index = entry.indexOf('=');
		if (index != -1) {
			String key = entry.substring(0, index);
			String value = entry.substring(index + 1);
			return new Entry(key, value);
		}
		return new Entry(entry, null);
	}

	/**
	 * Return the env as a {@link Map}.
	 * @return the env as a map
	 */
	Map<String, @Nullable String> asMap() {
		return this.map;
	}

	private record Entry(String key, @Nullable String value) {

	}

}

Analyze Your Own Codebase

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

Try Supermodel Free