mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
allow inline deprecation of activity params
This commit is contained in:
parent
d8688ad167
commit
8ba0684b8d
@ -18,6 +18,7 @@ package io.nosqlbench.api.engine.activityimpl;
|
||||
|
||||
import io.nosqlbench.api.config.NBNamedElement;
|
||||
import io.nosqlbench.api.engine.util.Unit;
|
||||
import io.nosqlbench.api.errors.BasicError;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
@ -213,4 +214,22 @@ public class ActivityDef implements NBNamedElement {
|
||||
public String getName() {
|
||||
return getAlias();
|
||||
}
|
||||
|
||||
public ActivityDef deprecate(String deprecatedName, String newName) {
|
||||
Object deprecatedParam = this.parameterMap.get(deprecatedName);
|
||||
if (deprecatedParam==null) {
|
||||
return this;
|
||||
}
|
||||
if (deprecatedParam instanceof CharSequence chars) {
|
||||
if (this.parameterMap.containsKey(newName)) {
|
||||
throw new BasicError("You have specified activity param '" + deprecatedName + "' in addition to the valid name '" + newName +"'. Remove '" + deprecatedName + "'.");
|
||||
} else {
|
||||
logger.warn("Auto replacing deprecated activity param " + deprecatedName + " with new '" + newName +"="+ chars +".");
|
||||
parameterMap.put(newName,parameterMap.remove(deprecatedParam));
|
||||
}
|
||||
} else {
|
||||
throw new BasicError("Can't replace deprecated name with value of type " + deprecatedName.getClass().getCanonicalName());
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user