provide a default empty configuration

This commit is contained in:
Jonathan Shook 2021-12-21 13:07:54 -06:00
parent b1e915a4b8
commit 3a0186fef4
2 changed files with 13 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package io.nosqlbench.nb.api.config.standard;
import io.nosqlbench.engine.api.activityimpl.ActivityDef;
import io.nosqlbench.nb.api.errors.BasicError;
import java.math.BigDecimal;
@ -27,6 +28,14 @@ public class ConfigModel implements NBConfigModel {
return new ConfigModel(ofType);
}
public static NBConfiguration defacto(ActivityDef def) {
ConfigModel configModel = new ConfigModel(Object.class);
for (Map.Entry<String, Object> entry : def.getParams().entrySet()) {
configModel.add(Param.defaultTo(entry.getKey(),entry.getValue().toString()));
}
return configModel.apply(def.getParams());
}
public <T> ConfigModel add(Param<T> param) {
this.params.add(param);
for (String name : param.getNames()) {

View File

@ -25,6 +25,10 @@ public class NBConfiguration {
this.model = model;
}
public static NBConfiguration empty() {
return new NBConfiguration(ConfigModel.of(Object.class).asReadOnly(),new LinkedHashMap<>());
}
/**
* Returns the value of the named parameter as {@link #getOptional(String)}, so long
* as no env vars were reference OR all env var references were found.