aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2023-07-06 16:25:03 +0200
committersonartech <sonartech@sonarsource.com>2023-07-17 20:03:45 +0000
commitf33d112357996fc67a2fc10884b4dafe7737d5c0 (patch)
treef71983218ba7eb0f0679011e006254f6826d7b98
parent1ade7f5774b98e129d2a79e6adf7450861e5ba9e (diff)
downloadsonarqube-f33d112357996fc67a2fc10884b4dafe7737d5c0.tar.gz
sonarqube-f33d112357996fc67a2fc10884b4dafe7737d5c0.zip
NO-JIRA replace MoreCollectors.toImmutableList with ImmutableList.toImmutableList from guava
-rw-r--r--server/sonar-server-common/src/main/java/org/sonar/server/es/response/NodeStatsResponse.java5
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java4
-rw-r--r--sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java6
-rw-r--r--sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java16
4 files changed, 6 insertions, 25 deletions
diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/response/NodeStatsResponse.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/response/NodeStatsResponse.java
index b66b20640ae..93e8f6cf9d9 100644
--- a/server/sonar-server-common/src/main/java/org/sonar/server/es/response/NodeStatsResponse.java
+++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/response/NodeStatsResponse.java
@@ -25,7 +25,8 @@ import com.google.gson.JsonObject;
import java.util.List;
import java.util.Map;
import javax.annotation.concurrent.Immutable;
-import org.sonar.core.util.stream.MoreCollectors;
+
+import static com.google.common.collect.ImmutableList.toImmutableList;
@Immutable
public class NodeStatsResponse {
@@ -37,7 +38,7 @@ public class NodeStatsResponse {
.map(Map.Entry::getValue)
.map(JsonElement::getAsJsonObject)
.map(NodeStats::toNodeStats)
- .collect(MoreCollectors.toImmutableList());
+ .collect(toImmutableList());
}
public static NodeStatsResponse toNodeStatsResponse(JsonObject jsonObject) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java
index 1ddbb7621ce..f1426313523 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/RegisterQualityGates.java
@@ -34,7 +34,6 @@ import org.slf4j.LoggerFactory;
import org.sonar.api.Startable;
import org.sonar.api.utils.System2;
import org.sonar.core.util.UuidFactory;
-import org.sonar.core.util.stream.MoreCollectors;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.metric.MetricDto;
@@ -44,6 +43,7 @@ import org.sonar.db.qualitygate.QualityGateDao;
import org.sonar.db.qualitygate.QualityGateDto;
import org.sonar.server.measure.Rating;
+import static com.google.common.collect.ImmutableList.toImmutableList;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toMap;
import static org.sonar.api.measures.CoreMetrics.NEW_COVERAGE_KEY;
@@ -132,7 +132,7 @@ public class RegisterQualityGates implements Startable {
return qualityGateConditionDao.selectForQualityGate(dbSession, builtinQualityGate.getUuid())
.stream()
.map(dto -> QualityGateCondition.from(dto, uuidToKeyMetric))
- .collect(MoreCollectors.toImmutableList());
+ .collect(toImmutableList());
}
private List<QualityGateCondition> removeExtraConditions(DbSession dbSession, QualityGateDto builtinQualityGate, List<QualityGateCondition> qualityGateConditions) {
diff --git a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
index 96895b3ac26..a5aca3d37b9 100644
--- a/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
+++ b/sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
@@ -20,7 +20,6 @@
package org.sonar.core.util.stream;
import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
@@ -51,14 +50,11 @@ public final class MoreCollectors {
// prevents instantiation
}
- public static <E> Collector<E, ?, ImmutableList<E>> toImmutableList() {
- return ImmutableList.toImmutableList();
- }
-
public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
return ImmutableSet.toImmutableSet();
}
+
/**
* A Collector into an {@link EnumSet} of specified enumeration.
*/
diff --git a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
index 32a4c679fe3..18d841338cc 100644
--- a/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
+++ b/sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java
@@ -20,7 +20,6 @@
package org.sonar.core.util.stream;
import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ListMultimap;
import com.google.common.collect.SetMultimap;
@@ -45,7 +44,6 @@ import static org.sonar.core.util.stream.MoreCollectors.index;
import static org.sonar.core.util.stream.MoreCollectors.join;
import static org.sonar.core.util.stream.MoreCollectors.toArrayList;
import static org.sonar.core.util.stream.MoreCollectors.toHashSet;
-import static org.sonar.core.util.stream.MoreCollectors.toImmutableList;
import static org.sonar.core.util.stream.MoreCollectors.toImmutableSet;
import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
import static org.sonar.core.util.stream.MoreCollectors.unorderedFlattenIndex;
@@ -72,20 +70,6 @@ public class MoreCollectorsTest {
@Test
- public void toList_builds_an_ImmutableList() {
- List<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toImmutableList());
- assertThat(res).isInstanceOf(ImmutableList.class)
- .containsExactly(1, 2, 3, 4, 5);
- }
-
- @Test
- public void toList_with_size_builds_an_ImmutableList() {
- List<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toImmutableList());
- assertThat(res).isInstanceOf(ImmutableList.class)
- .containsExactly(1, 2, 3, 4, 5);
- }
-
- @Test
public void toSet_builds_an_ImmutableSet() {
Set<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toImmutableSet());
assertThat(res).isInstanceOf(ImmutableSet.class)