cdc.mf.html.adaptors.RuleAdaptor Maven / Gradle / Ivy
package cdc.mf.html.adaptors;
import org.stringtemplate.v4.Interpreter;
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.misc.ObjectModelAdaptor;
import org.stringtemplate.v4.misc.STNoSuchPropertyException;
import cdc.issues.rules.Rule;
import cdc.mf.html.MfHtmlGenerationArgs;
import cdc.mf.html.MfParams;
public class RuleAdaptor extends ObjectModelAdaptor {
private final MfHtmlGenerationArgs args;
public RuleAdaptor(MfHtmlGenerationArgs args) {
this.args = args;
}
@Override
public synchronized Object getProperty(Interpreter interp,
ST self,
Rule rule,
Object property,
String propertyName) throws STNoSuchPropertyException {
switch (propertyName) {
case "id":
return MfParams.getId(rule);
case "htmlId":
return MfParams.getHtmlId(rule);
case "description":
return MfParams.toHtml(rule.getDescription(), args);
case "issues":
// The issues associated to rule
return args.getIssues(rule);
case "hasIssues":
return args.hasIssues(rule);
case "enabled":
return args.getProfile().isEnabled(rule);
case "checksResult":
if (args.getProfile().isEnabled(rule)) {
if (args.hasIssues(rule)) {
return "FAILED";
} else {
return "PASSED";
}
} else {
return null;
}
default:
break;
}
return super.getProperty(interp, self, rule, property, propertyName);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy