本文整理汇总了Java中org.sonar.api.measures.Metric.Level方法的典型用法代码示例。如果您正苦于以下问题:Java Metric.Level方法的具体用法?Java Metric.Level怎么用?Java Metric.Level使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.measures.Metric
的用法示例。
在下文中一共展示了Metric.Level方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: decorateResource
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
private void decorateResource(DecoratorContext context) {
for (final Alert alert : profile.getAlerts()) {
Measure measure = context.getMeasure(alert.getMetric());
if (measure == null) {
return;
}
Metric.Level level = AlertUtils.getLevel(alert, measure);
if (level == Metric.Level.OK) {
return;
}
LOG.debug("Alert raised on file {}: {} with level {}", context.getResource(), alert.getMetric().getName(), level);
measure.setAlertStatus(level);
measure.setAlertText(getText(alert, level));
context.saveMeasure(measure);
}
}
示例2: getAlertLabel
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
private String getAlertLabel(Alert alert, Metric.Level level) {
Integer alertPeriod = alert.getPeriod();
String metric = i18n.message(getLocale(), "metric." + alert.getMetric().getKey() + ".name", alert.getMetric().getName());
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(metric);
if (alertPeriod != null && !alert.getMetric().getKey().startsWith(VARIATION_METRIC_PREFIX)) {
String variation = i18n.message(getLocale(), VARIATION, VARIATION).toLowerCase();
stringBuilder.append(" ").append(variation);
}
stringBuilder
.append(" ").append(alert.getOperator()).append(" ")
.append(level.equals(Metric.Level.ERROR) ? alert.getValueError() : alert.getValueWarning());
// if (alertPeriod != null) {
// stringBuilder.append(" ").append(periods.label(snapshot, alertPeriod));
// }
return stringBuilder.toString();
}
示例3: getLevel
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
/**
* Get the matching alert level for the given measure
*/
public static Metric.Level getLevel(Alert alert, Measure measure) {
if (evaluateAlert(alert, measure, Metric.Level.ERROR)) {
return Metric.Level.ERROR;
}
if (evaluateAlert(alert, measure, Metric.Level.WARN)) {
return Metric.Level.WARN;
}
return Metric.Level.OK;
}
示例4: evaluateAlert
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
private static boolean evaluateAlert(Alert alert, Measure measure, Metric.Level alertLevel) {
String valueToEval = getValueToEval(alert, alertLevel);
if (StringUtils.isEmpty(valueToEval)) {
return false;
}
Comparable criteriaValue = getValueForComparison(alert.getMetric(), valueToEval);
Comparable measureValue = getMeasureValue(alert, measure);
if (measureValue != null) {
return doesReachThresholds(measureValue, criteriaValue, alert);
}
return false;
}
示例5: getValueToEval
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
private static String getValueToEval(Alert alert, Metric.Level alertLevel) {
if (alertLevel.equals(Metric.Level.ERROR)) {
return alert.getValueError();
} else if (alertLevel.equals(Metric.Level.WARN)) {
return alert.getValueWarning();
} else {
throw new IllegalStateException(alertLevel.toString());
}
}
示例6: getText
import org.sonar.api.measures.Metric; //导入方法依赖的package包/类
private String getText(Alert alert, Metric.Level level) {
if (level == Metric.Level.OK) {
return null;
}
return getAlertLabel(alert, level);
}