@CheckForNull private static Comparable getValue(QualityGateEvaluator.Measure measure) { if (NUMERICAL_TYPES.contains(measure.getType())) { return measure.getValue().isPresent() ? getNumericValue(measure.getType(), measure.getValue().getAsDouble()) : null; } checkArgument(ValueType.LEVEL.equals(measure.getType()), "Condition is not allowed for type %s" , measure.getType()); return measure.getStringValue().orElse(null); }
private static Ordering<ComponentDto> metricValueOrdering(ComponentTreeRequest wsRequest, List<MetricDto> metrics, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) { if (wsRequest.getMetricSort() == null) { return componentNameOrdering(wsRequest.getAsc()); } Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDto::getKey); MetricDto metric = metricsByKey.get(wsRequest.getMetricSort()); boolean isAscending = wsRequest.getAsc(); ValueType metricValueType = ValueType.valueOf(metric.getValueType()); if (NUMERIC_VALUE_TYPES.contains(metricValueType)) { return numericalMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } else if (TEXTUAL_VALUE_TYPES.contains(metricValueType)) { return stringOrdering(isAscending, new ComponentDtoToTextualMeasureValue(metric, measuresByComponentUuidAndMetric)); } else if (ValueType.LEVEL.equals(ValueType.valueOf(metric.getValueType()))) { return levelMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } throw new IllegalStateException("Unrecognized metric value type: " + metric.getValueType()); }
this.userManaged = userManaged; this.origin = Origin.JAV; if (ValueType.PERCENT.equals(this.type)) { this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0); this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0);
private static Ordering<ComponentDto> metricValueOrdering(ComponentTreeRequest wsRequest, List<MetricDto> metrics, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) { if (wsRequest.getMetricSort() == null) { return componentNameOrdering(wsRequest.getAsc()); } Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDto::getKey); MetricDto metric = metricsByKey.get(wsRequest.getMetricSort()); boolean isAscending = wsRequest.getAsc(); ValueType metricValueType = ValueType.valueOf(metric.getValueType()); if (NUMERIC_VALUE_TYPES.contains(metricValueType)) { return numericalMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } else if (TEXTUAL_VALUE_TYPES.contains(metricValueType)) { return stringOrdering(isAscending, new ComponentDtoToTextualMeasureValue(metric, measuresByComponentUuidAndMetric)); } else if (ValueType.LEVEL.equals(ValueType.valueOf(metric.getValueType()))) { return levelMetricOrdering(isAscending, metric, measuresByComponentUuidAndMetric); } throw new IllegalStateException("Unrecognized metric value type: " + metric.getValueType()); }
private String alertValue(ResolvedCondition condition, Metric.Level level) { String value = level.equals(Metric.Level.ERROR) ? condition.errorThreshold() : condition.warningThreshold(); if (condition.metric().getType().equals(Metric.ValueType.WORK_DUR)) { return formatDuration(value); } else { return value; } }
/** * @return whether the metric is of a numeric type (int, percentage...) */ public boolean isNumericType() { return ValueType.INT.equals(type) || ValueType.FLOAT.equals(type) || ValueType.PERCENT.equals(type) || ValueType.BOOL.equals(type) || ValueType.MILLISEC.equals(type) || ValueType.RATING.equals(type) || ValueType.WORK_DUR.equals(type); }
/** * Creates a new metric definition based on the properties set on this metric builder. * * @return a new {@link Metric} object */ public <G extends Serializable> Metric<G> create() { if (ValueType.PERCENT.equals(this.type)) { this.bestValue = (direction == DIRECTION_BETTER ? 100.0 : 0.0); this.worstValue = (direction == DIRECTION_BETTER ? 0.0 : 100.0); } return new Metric<G>(this); } }
/** * @return whether the metric is of type percentage */ public boolean isPercentageType() { return ValueType.PERCENT.equals(type); }
/** * @return whether the metric is of type percentage */ public boolean isPercentageType() { return ValueType.PERCENT.equals(type); }
/** * @return whether the metric is of a numeric type (int, percentage...) */ public boolean isNumericType() { return ValueType.INT.equals(type) || ValueType.FLOAT.equals(type) || ValueType.PERCENT.equals(type) || ValueType.BOOL.equals(type) || ValueType.MILLISEC.equals(type) || ValueType.RATING.equals(type) || ValueType.WORK_DUR.equals(type); }
/** * @return whether the metric is of a numeric type (int, percentage...) */ public boolean isNumericType() { return ValueType.INT.equals(type) || ValueType.FLOAT.equals(type) || ValueType.PERCENT.equals(type) || ValueType.BOOL.equals(type) || ValueType.MILLISEC.equals(type) || ValueType.RATING.equals(type) || ValueType.WORK_DUR.equals(type); }
/** * @return whether the metric is of type percentage */ public boolean isPercentageType() { return ValueType.PERCENT.equals(type); }