aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-db
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-12 12:45:48 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2016-01-20 12:45:58 +0100
commite678c88a913dd1eacb0c334ad87769a8d120c3b3 (patch)
tree41a2b19f0238ad9886a03d29b5794dbb1bdb0d9b /sonar-db
parentec96c3e2c8e33bc40e519a7b9566cfb2e9338b52 (diff)
downloadsonarqube-e678c88a913dd1eacb0c334ad87769a8d120c3b3.tar.gz
sonarqube-e678c88a913dd1eacb0c334ad87769a8d120c3b3.zip
SONAR-7134 WS api/measures/component
Diffstat (limited to 'sonar-db')
-rw-r--r--sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java42
-rw-r--r--sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java14
2 files changed, 56 insertions, 0 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java
new file mode 100644
index 00000000000..6a189b51c92
--- /dev/null
+++ b/sonar-db/src/main/java/org/sonar/db/measure/MeasureDtoFunctions.java
@@ -0,0 +1,42 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonar.db.measure;
+
+import com.google.common.base.Function;
+import javax.annotation.Nonnull;
+
+public class MeasureDtoFunctions {
+ private MeasureDtoFunctions() {
+ // prevent instantiation
+ }
+
+ public static Function<MeasureDto, Integer> toMetricId() {
+ return ToMetricId.INSTANCE;
+ }
+
+ private enum ToMetricId implements Function<MeasureDto, Integer> {
+ INSTANCE;
+
+ @Override
+ public Integer apply(@Nonnull MeasureDto input) {
+ return input.getMetricId();
+ }
+ }
+}
diff --git a/sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java b/sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java
index c97aba3b698..f2111f7066f 100644
--- a/sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java
+++ b/sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java
@@ -20,6 +20,7 @@
package org.sonar.db.metric;
import com.google.common.base.Function;
+import com.google.common.base.Predicate;
import javax.annotation.Nonnull;
/**
@@ -38,6 +39,10 @@ public class MetricDtoFunctions {
return ToKey.INSTANCE;
}
+ public static Predicate<MetricDto> isOptimizedForBestValue() {
+ return IsMetricOptimizedForBestValue.INSTANCE;
+ }
+
private enum ToId implements Function<MetricDto, Integer> {
INSTANCE;
@@ -55,4 +60,13 @@ public class MetricDtoFunctions {
return input.getKey();
}
}
+
+ private enum IsMetricOptimizedForBestValue implements Predicate<MetricDto> {
+ INSTANCE;
+
+ @Override
+ public boolean apply(@Nonnull MetricDto input) {
+ return input.isOptimizedBestValue() && input.getBestValue() != null;
+ }
+ }
}