re-use base config model

This commit is contained in:
Jonathan Shook 2021-12-22 14:05:19 -06:00
parent eae115afae
commit ceee8c59c0
3 changed files with 17 additions and 7 deletions

View File

@ -29,6 +29,6 @@ public class DynamoDBDriverAdapter extends BaseDriverAdapter<DynamoDBOp, DynamoD
@Override
public NBConfigModel getConfigModel() {
return DynamoDBSpace.getConfigModel();
return super.getConfigModel().add(DynamoDBSpace.getConfigModel());
}
}

View File

@ -2,10 +2,7 @@ package io.nosqlbench.engine.api.activityimpl.uniform;
import io.nosqlbench.engine.api.activityimpl.uniform.fieldmappers.FieldDestructuringMapper;
import io.nosqlbench.engine.api.activityimpl.uniform.flowtypes.Op;
import io.nosqlbench.nb.api.config.standard.ConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfigModel;
import io.nosqlbench.nb.api.config.standard.NBConfigurable;
import io.nosqlbench.nb.api.config.standard.NBConfiguration;
import io.nosqlbench.nb.api.config.standard.*;
import java.util.ArrayList;
import java.util.List;
@ -95,7 +92,8 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
*/
@Override
public NBConfigModel getConfigModel() {
return ConfigModel.of(this.getClass());
return ConfigModel.of(this.getClass())
.add(Param.defaultTo("errors","stop","Configure the error handler"));
}
@Override

View File

@ -14,7 +14,7 @@ public class Param<T> {
private final List<String> names;
public final Class<? extends T> type;
public String description;
private String description;
private final T defaultValue;
public boolean required;
private Pattern regex;
@ -89,6 +89,18 @@ public class Param<T> {
return new Param<V>(List.of(name), (Class<V>) defaultValue.getClass(), null, true, defaultValue);
}
/**
* Parameters which are given a default value are automatically marked as required, as the default
* value allows them to be accessed as such.
* @param name
* @param defaultValue
* @param <V>
* @return
*/
public static <V> Param<V> defaultTo(String name, V defaultValue, String description) {
return new Param<V>(List.of(name), (Class<V>) defaultValue.getClass(), description, true, defaultValue);
}
/**
* Parameters which are given a default value are automatically marked as required, as the default
* value allows them to be accessed as such.