allow easy include/exclude of cql driver versions

This commit is contained in:
Jonathan Shook 2021-07-22 18:50:11 -05:00
parent f244c0f225
commit 03f7f13c2b
3 changed files with 47 additions and 16 deletions

View File

@ -74,8 +74,9 @@ public class NBConfiguration {
if (param==null) {
throw new NBConfigError("Parameter named '" + name + "' is not valid for " + model.getOf().getSimpleName() + ".");
}
if (!param.isRequired()) {
throw new NBConfigError("Non-optional get on parameter declared optional '" + name + "'");
if ((!param.isRequired())&&param.getDefaultValue()==null) {
throw new RuntimeException("Non-optional get on optional parameter " + name + "' which has no default value while configuring " + model.getOf() + "." +
"\nTo avoid user impact, ensure that ConfigModel and NBConfigurable usage are aligned.");
}
Object o = data.get(name);

View File

@ -77,12 +77,28 @@ public class Param<T> {
return new Param<V>(List.of(name), type, null, false, null);
}
/**
* 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) {
return new Param<V>(List.of(name), (Class<V>) defaultValue.getClass(), null, false, null);
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 names
* @param defaultValue
* @param <V>
* @return
*/
public static <V> Param<V> defaultTo(List<String> names, V defaultValue) {
return new Param<V>(names, (Class<V>) defaultValue.getClass(), null, false, null);
return new Param<V>(names, (Class<V>) defaultValue.getClass(), null, true, defaultValue);
}
public static <V> Param<V> required(String name, Class<V> type) {

View File

@ -93,18 +93,6 @@
<version>4.15.52-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>driver-dsegraph-shaded</artifactId>
<version>4.15.52-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>driver-cql-shaded</artifactId>
<version>4.15.52-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>driver-cqld3-shaded</artifactId>
@ -222,6 +210,32 @@
</build>
<profiles>
<profile>
<id>with-dsegraph-d1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>driver-dsegraph-shaded</artifactId>
<version>4.15.52-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>with-cql-d1</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>io.nosqlbench</groupId>
<artifactId>driver-cql-shaded</artifactId>
<version>4.15.52-SNAPSHOT</version>
</dependency>
</dependencies>
</profile>
<profile>
<id>with-cql-d4</id>
<activation>