本文整理汇总了Java中org.sonar.squidbridge.annotations.RuleTemplate类的典型用法代码示例。如果您正苦于以下问题:Java RuleTemplate类的具体用法?Java RuleTemplate怎么用?Java RuleTemplate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RuleTemplate类属于org.sonar.squidbridge.annotations包,在下文中一共展示了RuleTemplate类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newRule
import org.sonar.squidbridge.annotations.RuleTemplate; //导入依赖的package包/类
@VisibleForTesting
protected void newRule(Class<?> ruleClass, NewRepository repository) {
org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(ruleClass, org.sonar.check.Rule.class);
if (ruleAnnotation == null) {
throw new IllegalArgumentException("No Rule annotation was found on " + ruleClass);
}
String ruleKey = ruleAnnotation.key();
if (StringUtils.isEmpty(ruleKey)) {
throw new IllegalArgumentException("No key is defined in Rule annotation of " + ruleClass);
}
NewRule rule = repository.rule(ruleKey);
if (rule == null) {
throw new IllegalStateException("No rule was created for " + ruleClass + " in " + repository.key());
}
ruleMetadata(ruleClass, rule);
rule.setTemplate(AnnotationUtils.getAnnotation(ruleClass, RuleTemplate.class) != null);
if (ruleAnnotation.cardinality() == Cardinality.MULTIPLE) {
throw new IllegalArgumentException("Cardinality is not supported, use the RuleTemplate annotation instead for " + ruleClass);
}
}