aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-06-16 10:20:29 +0200
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-06-18 10:13:16 +0200
commit1eea485b14b3af360250a2302e9557dd615ef492 (patch)
treee586eac1c91d08327f80f47419f5ec7b0865a490 /sonar-plugin-api
parent854ad6d7c995fd183b21fc4353c088516e27d1d8 (diff)
downloadsonarqube-1eea485b14b3af360250a2302e9557dd615ef492.tar.gz
sonarqube-1eea485b14b3af360250a2302e9557dd615ef492.zip
SONAR-6610 WS custom_measures/create create a custom measure
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/PropertyType.java16
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/Metric.java15
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java3
3 files changed, 30 insertions, 4 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyType.java b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyType.java
index 292a298c7e2..06c2e867c3a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/PropertyType.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/PropertyType.java
@@ -83,8 +83,18 @@ public enum PropertyType {
PROPERTY_SET,
/**
- * User login
- * @since 5.1
+ * User login
+ * @since 5.1
+ */
+ USER_LOGIN,
+
+ /**
+ * Level metric type
+ */
+ METRIC_LEVEL,
+
+ /**
+ * Work duration metric type
*/
- USER_LOGIN
+ METRIC_WORK_DURATION
}
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 987be1d33e4..b02bc030b8e 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
@@ -19,8 +19,13 @@
*/
package org.sonar.api.measures;
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
import java.io.Serializable;
+import java.util.Arrays;
+import java.util.List;
import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -124,6 +129,16 @@ public class Metric<G extends Serializable> implements Serializable, org.sonar.a
public String getColorName() {
return colorName;
}
+
+ public static List<String> names() {
+ return Lists.transform(Arrays.asList(values()), new Function<Level, String>() {
+ @Nonnull
+ @Override
+ public String apply(@Nonnull Level level) {
+ return level.name();
+ }
+ });
+ }
}
@Id
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java
index 4f88279c6d5..bfaa830b94a 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/utils/Durations.java
@@ -63,7 +63,8 @@ public class Durations {
/**
* Convert the text to a Duration
* <br>
- * Example : decode("9d 10 h") -> Duration.encode("10d2h") (if sonar.technicalDebt.hoursInDay property is set to 8)
+ * Example : decode("9d 10 h") -> Duration.encode("10d2h") (if sonar.technicalDebt.hoursInDay property is set to 8)<br />
+ * Throws {@code IllegalArgumentException}
*/
public Duration decode(String duration) {
return Duration.decode(duration, hoursInDay());