diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-12 12:45:48 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2016-01-20 12:45:58 +0100 |
commit | e678c88a913dd1eacb0c334ad87769a8d120c3b3 (patch) | |
tree | 41a2b19f0238ad9886a03d29b5794dbb1bdb0d9b /sonar-db | |
parent | ec96c3e2c8e33bc40e519a7b9566cfb2e9338b52 (diff) | |
download | sonarqube-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.java | 42 | ||||
-rw-r--r-- | sonar-db/src/main/java/org/sonar/db/metric/MetricDtoFunctions.java | 14 |
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; + } + } } |