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;
/**
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) {
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;
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;
.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);
}
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;
// prevents instantiation
}
- public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
- return ImmutableSet.toImmutableSet();
- }
-
/**
* A Collector into an {@link EnumSet} of specified enumeration.
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;
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;
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));