mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
improved error messages
This commit is contained in:
@@ -60,7 +60,18 @@ public class StmtDef implements OpTemplate {
|
||||
public <T> Map<String, T> getParamsAsValueType(Class<? extends T> type) {
|
||||
MultiMapLookup<Object> lookup = new MultiMapLookup<>(rawStmtDef.getParams(), block.getParams());
|
||||
Map<String, T> map = new LinkedHashMap<>();
|
||||
lookup.forEach((k,v)->map.put(k,type.cast(v)));
|
||||
//TODO put type guard around casting below
|
||||
for (String pname : lookup.keySet()) {
|
||||
Object object = lookup.get(pname);
|
||||
if (type.isAssignableFrom(object.getClass())) {
|
||||
map.put(pname, type.cast(object));
|
||||
} else {
|
||||
throw new RuntimeException("With param named '" + pname + "" +
|
||||
"' You can't assign an object of type '" + object.getClass().getSimpleName() + "" +
|
||||
"' to '" + type.getSimpleName() + "'");
|
||||
}
|
||||
}
|
||||
// lookup.forEach((k,v)->map.put(k,type.cast(v)));
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user