3 * Copyright (C) 2009-2024 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.ce.task.projectanalysis.metric;
22 import javax.annotation.CheckForNull;
23 import org.sonar.ce.task.projectanalysis.measure.Measure;
25 public interface Metric {
27 * The metric's uuid (ie. its database identifier)
32 * The Metric's key is its domain identifier.
41 * When Metric is "bestValueOptimized" _and_ the component it belongs to is a FILE, any measure which has the same
42 * value as the best value of the metric should _not_ be persisted into the DB to save on DB usage.
44 boolean isBestValueOptimized();
47 * The best value for the current Metric, if there is any
50 Double getBestValue();
53 * The decimal scale of float measures. Returned value is greater than or equal zero.
54 * @throws IllegalStateException if the value type is not decimal (see {@link org.sonar.ce.task.projectanalysis.measure.Measure.ValueType}
56 int getDecimalScale();
58 boolean isDeleteHistoricalData();
61 INT(Measure.ValueType.INT),
62 MILLISEC(Measure.ValueType.LONG),
63 RATING(Measure.ValueType.INT),
64 WORK_DUR(Measure.ValueType.LONG),
65 FLOAT(Measure.ValueType.DOUBLE),
66 PERCENT(Measure.ValueType.DOUBLE),
67 BOOL(Measure.ValueType.BOOLEAN),
68 STRING(Measure.ValueType.STRING),
69 DISTRIB(Measure.ValueType.STRING),
70 DATA(Measure.ValueType.STRING),
71 LEVEL(Measure.ValueType.LEVEL);
73 private final Measure.ValueType valueType;
75 MetricType(Measure.ValueType valueType) {
76 this.valueType = valueType;
79 public Measure.ValueType getValueType() {