aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-20 15:55:34 +0200
committerJulien Lancelot <julien.lancelot@sonarsource.com>2014-05-20 16:21:10 +0200
commit28d2cf2e08e4d8dd42904e8fc1db92e50905e54b (patch)
tree19dec5638bb87720ae45522ebbed1d5cad4cb659 /sonar-plugin-api
parente490ee5188bc25eab1cd03fbd9f2df55301db370 (diff)
downloadsonarqube-28d2cf2e08e4d8dd42904e8fc1db92e50905e54b.tar.gz
sonarqube-28d2cf2e08e4d8dd42904e8fc1db92e50905e54b.zip
SONAR-5305 Do only one SQL to retun all measures
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
index 6399bff81b3..97571eb20ad 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/measures/CoreMetrics.java
@@ -20,10 +20,14 @@
package org.sonar.api.measures;
import com.google.common.annotations.Beta;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.sonar.api.resources.Scopes;
import org.sonar.api.utils.SonarException;
+import javax.annotation.Nullable;
+
import java.lang.reflect.Field;
import java.util.List;
@@ -2286,4 +2290,13 @@ public final class CoreMetrics {
public static List<Metric> getMetrics() {
return METRICS;
}
+
+ public static Metric getMetric(final String key) {
+ return Iterables.find(METRICS, new Predicate<Metric>() {
+ @Override
+ public boolean apply(@Nullable Metric input) {
+ return input != null && input.getKey().equals(key);
+ }
+ });
+ }
}