apoc.model.ModelConfig Maven / Gradle / Ivy
package apoc.model;
import apoc.util.Util;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class ModelConfig {
private final boolean write;
private final String schema;
private final List tables;
private final List views;
private final List columns;
public ModelConfig(Map config) {
this.write = Util.toBoolean(config.getOrDefault("write",false));
Map> filters = (Map>) config.getOrDefault("filters", Collections.emptyMap());
this.tables = toPatternList(filters.getOrDefault("tables", Collections.emptyList()));
this.views = toPatternList(filters.getOrDefault("views", Collections.emptyList()));
this.columns = toPatternList(filters.getOrDefault("columns", Collections.emptyList()));
this.schema = config.getOrDefault("schema", "").toString();
}
private List toPatternList(List patterns) {
return patterns
.stream()
.collect(Collectors.toList());
}
public List getViews() {
return views;
}
public List getColumns() {
return columns;
}
public boolean isWrite() {
return write;
}
public List getTables() {
return tables;
}
public String getSchema() {
return schema;
}
}