]> source.dussan.org Git - sonarqube.git/commitdiff
NO-JIRA replace MoreCollectors.toImmutableSet with ImmutableSet.toImmutableSet from...
authorPierre <pierre.guillot@sonarsource.com>
Thu, 6 Jul 2023 14:26:12 +0000 (16:26 +0200)
committersonartech <sonartech@sonarsource.com>
Mon, 17 Jul 2023 20:03:45 +0000 (20:03 +0000)
server/sonar-webserver-api/src/main/java/org/sonar/server/qualitygate/changeevent/QGChangeEventListenersImpl.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/BulkDeleteAction.java
sonar-core/src/main/java/org/sonar/core/util/stream/MoreCollectors.java
sonar-core/src/test/java/org/sonar/core/util/stream/MoreCollectorsTest.java

index c8c8c3dcbc3ad2b6c0d15096f60b7ecb1486630b..1d02f8926cc8e702813fbdda3b4a313ee308fd86 100644 (file)
@@ -30,6 +30,7 @@ import org.sonar.core.issue.DefaultIssue;
 import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.server.qualitygate.changeevent.QGChangeEventListener.ChangedIssue;
 
+import static com.google.common.collect.ImmutableSet.toImmutableSet;
 import static java.lang.String.format;
 
 /**
@@ -80,7 +81,7 @@ public class QGChangeEventListenersImpl implements QGChangeEventListeners {
   private static ImmutableSet<ChangedIssue> toChangedIssues(Collection<DefaultIssue> defaultIssues, boolean fromAlm) {
     return defaultIssues.stream()
       .map(defaultIssue -> new ChangedIssueImpl(defaultIssue, fromAlm))
-      .collect(MoreCollectors.toImmutableSet());
+      .collect(toImmutableSet());
   }
 
   private void broadcastChangeEventToListeners(Set<ChangedIssue> changedIssues, QGChangeEvent changeEvent) {
index f6647ccbbeb4efd12a2742ceb1cbfe61f0552c59..c71fcb9974ca4b80e6d8afded4eca9ebb4720658 100644 (file)
@@ -37,7 +37,6 @@ import org.sonar.api.server.ws.Response;
 import org.sonar.api.server.ws.WebService;
 import org.sonar.api.server.ws.WebService.Param;
 import org.sonar.api.utils.DateUtils;
-import org.sonar.core.util.stream.MoreCollectors;
 import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.component.BranchDto;
@@ -53,6 +52,7 @@ import org.sonar.server.project.Visibility;
 import org.sonar.server.user.UserSession;
 
 import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.collect.ImmutableSet.toImmutableSet;
 import static java.lang.Math.min;
 import static java.lang.String.format;
 import static java.util.stream.Collectors.toSet;
@@ -170,7 +170,7 @@ public class BulkDeleteAction implements ProjectsWsAction {
       .collect(Collectors.toMap(BranchDto::getProjectUuid, BranchDto::getUuid));
 
     ImmutableSet<DeletedProject> deletedProjects = entities.stream().map(entity -> new DeletedProject(Project.from(entity), mainBranchUuidByEntityUuid.get(entity.getUuid())))
-      .collect(MoreCollectors.toImmutableSet());
+      .collect(toImmutableSet());
     projectLifeCycleListeners.onProjectsDeleted(deletedProjects);
   }
 
index a5aca3d37b96c022a5970739f836e88ac944ae25..3dc04a631f69d7ff2d9edfdcb9e97561e44aab18 100644 (file)
@@ -22,7 +22,6 @@ package org.sonar.core.util.stream;
 import com.google.common.base.Joiner;
 import com.google.common.collect.ImmutableListMultimap;
 import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ImmutableSetMultimap;
 import java.util.ArrayList;
 import java.util.EnumSet;
@@ -50,10 +49,6 @@ public final class MoreCollectors {
     // prevents instantiation
   }
 
-  public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
-    return ImmutableSet.toImmutableSet();
-  }
-
 
   /**
    * A Collector into an {@link EnumSet} of specified enumeration.
index 18d841338cc0cfdf7f95bdfcb28ef89b1304fd50..16678ad3f74339a8119fefa15f26c38d7e1587e9 100644 (file)
@@ -20,7 +20,6 @@
 package org.sonar.core.util.stream;
 
 import com.google.common.base.Joiner;
-import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ListMultimap;
 import com.google.common.collect.SetMultimap;
 import java.util.ArrayList;
@@ -44,7 +43,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.toImmutableSet;
 import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex;
 import static org.sonar.core.util.stream.MoreCollectors.unorderedFlattenIndex;
 import static org.sonar.core.util.stream.MoreCollectors.unorderedIndex;
@@ -68,21 +66,6 @@ public class MoreCollectorsTest {
   private static final List<MyObj> LIST = Arrays.asList(MY_OBJ_1_A, MY_OBJ_2_B, MY_OBJ_3_C);
   private static final List<MyObj2> LIST2 = Arrays.asList(MY_OBJ2_1_A_X, MY_OBJ2_2_B, MY_OBJ2_3_C);
 
-
-  @Test
-  public void toSet_builds_an_ImmutableSet() {
-    Set<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toImmutableSet());
-    assertThat(res).isInstanceOf(ImmutableSet.class)
-      .containsExactly(1, 2, 3, 4, 5);
-  }
-
-  @Test
-  public void toSet_with_size_builds_an_ImmutableSet() {
-    Set<Integer> res = Stream.of(1, 2, 3, 4, 5).collect(toImmutableSet());
-    assertThat(res).isInstanceOf(ImmutableSet.class)
-      .containsExactly(1, 2, 3, 4, 5);
-  }
-
   @Test
   public void toEnumSet() {
     Set<MyEnum> res = Stream.of(MyEnum.ONE, MyEnum.ONE, MyEnum.TWO).collect(MoreCollectors.toEnumSet(MyEnum.class));