aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api/src/main/java
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-05-22 16:57:17 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-05-26 13:43:06 +0200
commit3c9e53b57a7d5a20d2f47d0462b53c10a587d250 (patch)
tree21ca9f923877b6132abb75a1c745351f09078b4a /sonar-plugin-api/src/main/java
parent958529665bd6e47b0f0cc43e4a73a3d8ca0f72f4 (diff)
downloadsonarqube-3c9e53b57a7d5a20d2f47d0462b53c10a587d250.tar.gz
sonarqube-3c9e53b57a7d5a20d2f47d0462b53c10a587d250.zip
WS api/metrics/list - SONAR-6570
Diffstat (limited to 'sonar-plugin-api/src/main/java')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java41
1 files changed, 28 insertions, 13 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
index 95035b48bcd..6c98862765d 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java
@@ -23,8 +23,8 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.sonar.api.batch.BatchSide;
-import org.sonar.api.server.ServerSide;
import org.sonar.api.batch.InstantiationStrategy;
+import org.sonar.api.server.ServerSide;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
@@ -65,28 +65,43 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a
public static final int DIRECTION_NONE = 0;
public enum ValueType {
- INT(Integer.class),
- FLOAT(Double.class),
- PERCENT(Double.class),
- BOOL(Boolean.class),
- STRING(String.class),
- MILLISEC(Integer.class),
- DATA(String.class),
- LEVEL(Metric.Level.class),
- DISTRIB(String.class),
- RATING(Integer.class),
- WORK_DUR(Long.class);
+ INT(Integer.class, "Integer"),
+ FLOAT(Double.class, "Float"),
+ PERCENT(Double.class, "Percent"),
+ BOOL(Boolean.class, "Yes/No"),
+ STRING(String.class, "String"),
+ MILLISEC(Integer.class, "Milliseconds"),
+ DATA(String.class, "Data"),
+ LEVEL(Metric.Level.class, "Level"),
+ DISTRIB(String.class, "Distribution"),
+ RATING(Integer.class, "Rating"),
+ WORK_DUR(Long.class, "Work Duration");
private final Class valueClass;
+ private final String description;
- private ValueType(Class valueClass) {
+ ValueType(Class valueClass, String description) {
this.valueClass = valueClass;
+ this.description = description;
}
private Class valueType() {
return valueClass;
}
+ public String description() {
+ return description;
+ }
+
+ public static String descriptionOf(String key) {
+ for (ValueType valueType : values()) {
+ if (valueType.name().equals(key)) {
+ return valueType.description;
+ }
+ }
+
+ throw new IllegalArgumentException(String.format("Unknown ValueType key '%s'", key));
+ }
}
public enum Level {