
com.github.sitture.envconfig.EnvConfigFileList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of env-config Show documentation
Show all versions of env-config Show documentation
A simple utility to manage environment configs in Java-based projects by merging *.properties files with environment variables overrides.
package com.github.sitture.envconfig;
import java.io.File;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
class EnvConfigFileList {
protected final Path configPath;
EnvConfigFileList(final Path configPath) {
this.configPath = configPath;
}
public List listFiles() {
final File configDir = configPath.toFile();
if (!configDir.exists() || !configDir.isDirectory()) {
throw new EnvConfigException(
"'" + configPath + "' does not exist or not a valid config directory!");
}
return getConfigProperties(configDir);
}
protected List getConfigProperties(final File configDir) {
final List files = Arrays.asList(Objects.requireNonNull(configDir.listFiles(new EnvConfigFileFilter())));
if (files.isEmpty()) {
throw new EnvConfigException("No property files found under '" + configDir.getPath() + "'");
}
return files;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy