liquibase.configuration.core.DefaultsFileValueProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of liquibase-core Show documentation
Show all versions of liquibase-core Show documentation
Liquibase is a tool for managing and executing database changes.
package liquibase.configuration.core;
import liquibase.GlobalConfiguration;
import liquibase.Scope;
import liquibase.command.CommandDefinition;
import liquibase.command.CommandFactory;
import liquibase.command.CommandScope;
import liquibase.configuration.AbstractMapConfigurationValueProvider;
import liquibase.configuration.LiquibaseConfiguration;
import liquibase.servicelocator.LiquibaseService;
import liquibase.util.StringUtil;
import java.io.*;
import java.nio.file.Files;
import java.util.Map;
import java.util.Properties;
import java.util.SortedSet;
import java.util.TreeSet;
@LiquibaseService(skip = true)
public class DefaultsFileValueProvider extends AbstractMapConfigurationValueProvider {
private final Properties properties;
private final String sourceDescription;
protected DefaultsFileValueProvider(Properties properties) {
this.properties = properties;
sourceDescription = "Passed default properties";
}
public DefaultsFileValueProvider(InputStream stream, String sourceDescription) throws IOException {
this.sourceDescription = sourceDescription;
this.properties = new Properties();
this.properties.load(stream);
trimAllProperties();
}
public DefaultsFileValueProvider(File path) throws IOException {
this.sourceDescription = "File " + path.getAbsolutePath();
try (InputStream stream = Files.newInputStream(path.toPath())) {
this.properties = new Properties();
this.properties.load(stream);
trimAllProperties();
}
}
@Override
public void validate(CommandScope commandScope) throws IllegalArgumentException {
boolean strict = GlobalConfiguration.STRICT.getCurrentValue();
SortedSet invalidKeys = new TreeSet<>();
for (Map.Entry