mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-22 15:13:41 -06:00
return default value if needed
This commit is contained in:
parent
795d63aa63
commit
23de45ca63
@ -148,8 +148,9 @@ public class NBConfiguration {
|
||||
|
||||
public <T> Optional<T> getOptional(Class<T> type, String... names) {
|
||||
Object o = null;
|
||||
Param<?> param=null;
|
||||
for (String name : names) {
|
||||
Param<?> param = model.getParam(names);
|
||||
param = model.getParam(names);
|
||||
if (param != null) {
|
||||
for (String pname : param.getNames()) {
|
||||
o = data.get(pname);
|
||||
@ -162,7 +163,11 @@ public class NBConfiguration {
|
||||
}
|
||||
}
|
||||
if (o == null) {
|
||||
return Optional.empty();
|
||||
if (param!=null && param.isRequired()) {
|
||||
o = param.getDefaultValue();
|
||||
} else {
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
if (type.isInstance(o)) {
|
||||
return Optional.of((T) o);
|
||||
|
Loading…
Reference in New Issue
Block a user