use of com.buschmais.jqassistant.core.rule.api.model.Parameter in project jqa-core-framework by buschmais.
the class AnalyzerRuleVisitor method getRuleParameters.
private Map<String, Object> getRuleParameters(ExecutableRule executableRule) throws RuleException {
Map<String, Object> ruleParameters = new HashMap<>();
Map<String, Parameter> parameters = executableRule.getParameters();
for (Map.Entry<String, Parameter> entry : parameters.entrySet()) {
String parameterName = entry.getKey();
Parameter parameter = entry.getValue();
Object parameterValue;
String parameterValueAsString = this.ruleParameters.get(parameterName);
if (parameterValueAsString != null) {
try {
parameterValue = parameter.getType().parse(parameterValueAsString);
} catch (RuleException e) {
throw new RuleException("Cannot determine value for parameter " + parameterName + "' of rule '" + executableRule + "'.");
}
} else {
parameterValue = parameter.getDefaultValue();
}
if (parameterValue == null) {
throw new RuleException("No value or default value defined for required parameter '" + parameterName + "' of rule '" + executableRule + "'.");
}
ruleParameters.put(parameterName, parameterValue);
}
return ruleParameters;
}
Aggregations