From 3a0186fef49113c340f6d42cf6e07d7798064cf6 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Tue, 21 Dec 2021 13:07:54 -0600 Subject: [PATCH] provide a default empty configuration --- .../nosqlbench/nb/api/config/standard/ConfigModel.java | 9 +++++++++ .../nb/api/config/standard/NBConfiguration.java | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/ConfigModel.java b/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/ConfigModel.java index b309d8391..bb319ed71 100644 --- a/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/ConfigModel.java +++ b/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/ConfigModel.java @@ -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 entry : def.getParams().entrySet()) { + configModel.add(Param.defaultTo(entry.getKey(),entry.getValue().toString())); + } + return configModel.apply(def.getParams()); + } + public ConfigModel add(Param param) { this.params.add(param); for (String name : param.getNames()) { diff --git a/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/NBConfiguration.java b/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/NBConfiguration.java index 1ee9923dd..1abf48a91 100644 --- a/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/NBConfiguration.java +++ b/nb-api/src/main/java/io/nosqlbench/nb/api/config/standard/NBConfiguration.java @@ -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.