diff options
author | Pierre <pierre.guillot@sonarsource.com> | 2023-07-06 16:12:30 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-07-17 20:03:44 +0000 |
commit | a0f29cb5c393c912f45c4d4e7f4c8a5679162b0d (patch) | |
tree | 4dd5c0622c70c639dac142701aa3cbcb45eb5e86 /server | |
parent | 5737b08804feb53257e712443b2eb69ab4607f47 (diff) | |
download | sonarqube-a0f29cb5c393c912f45c4d4e7f4c8a5679162b0d.tar.gz sonarqube-a0f29cb5c393c912f45c4d4e7f4c8a5679162b0d.zip |
NO-JIRA replace MoreCollectors.toList with Collectors.toList
Diffstat (limited to 'server')
87 files changed, 187 insertions, 195 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java index 4c5b08a0932..c52ec3d5dff 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/component/ComponentTreeBuilder.java @@ -27,12 +27,12 @@ import java.util.Map; import java.util.Objects; import java.util.function.Function; import java.util.function.UnaryOperator; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang.StringUtils; import org.sonar.ce.task.projectanalysis.analysis.Branch; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.scanner.protocol.output.ScannerReport; import org.sonar.scanner.protocol.output.ScannerReport.Component.FileStatus; import org.sonar.server.project.Project; @@ -252,7 +252,7 @@ public class ComponentTreeBuilder { return component.getChildren().stream() .map(ComponentTreeBuilder::buildChangedComponentTree) .filter(Objects::nonNull) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static ComponentImpl.Builder changedComponentBuilder(Component component, String newShortName) { diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitor.java index c387af15a56..ef20a4fdc9d 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitor.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/issue/IntegrateIssuesVisitor.java @@ -23,6 +23,7 @@ import java.util.Collection; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.sonar.ce.task.projectanalysis.component.Component; import org.sonar.ce.task.projectanalysis.component.CrawlerDepthLimit; @@ -32,7 +33,6 @@ import org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorAdapter; import org.sonar.ce.task.projectanalysis.util.cache.DiskCache.CacheAppender; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.tracking.Input; -import org.sonar.core.util.stream.MoreCollectors; import static org.sonar.ce.task.projectanalysis.component.ComponentVisitor.Order.POST_ORDER; @@ -113,7 +113,7 @@ public class IntegrateIssuesVisitor extends TypeAwareVisitorAdapter { private List<DefaultIssue> fillNewOpenIssues(Component component, Stream<DefaultIssue> newIssues, Input<DefaultIssue> rawInput) { List<DefaultIssue> newIssuesList = newIssues .peek(issueLifecycle::initNewOpenIssue) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); if (newIssuesList.isEmpty()) { return newIssuesList; diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/LoadProjectStep.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/LoadProjectStep.java index 01cf8a00120..171d283fa3d 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/LoadProjectStep.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectexport/steps/LoadProjectStep.java @@ -20,6 +20,7 @@ package org.sonar.ce.task.projectexport.steps; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.MessageException; import org.sonar.ce.task.projectexport.taskprocessor.ProjectDescriptor; import org.sonar.ce.task.step.ComputationStep; @@ -29,7 +30,6 @@ import org.sonar.db.component.BranchDto; import org.sonar.db.project.ProjectDto; import static java.lang.String.format; -import static org.sonar.core.util.stream.MoreCollectors.toList; /** * Loads project from database and verifies that it's valid: it must exist and be a project ! @@ -54,7 +54,7 @@ public class LoadProjectStep implements ComputationStep { .orElseThrow(() -> MessageException.of(format("Project with key [%s] does not exist", descriptor.getKey()))); definitionHolder.setProjectDto(project); - List<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream().collect(toList()); + List<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream().collect(Collectors.toList()); definitionHolder.setBranches(branches); } } diff --git a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java index eb3a3273a00..8b73d12b75d 100644 --- a/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java +++ b/server/sonar-db-core/src/it/java/org/sonar/db/DatabaseUtilsIT.java @@ -33,13 +33,13 @@ import java.util.Objects; import java.util.Optional; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; import org.slf4j.event.Level; import org.sonar.api.testfixtures.log.LogTester; import org.slf4j.LoggerFactory; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.dialect.Oracle; import static org.assertj.core.api.Assertions.assertThat; @@ -354,7 +354,7 @@ public class DatabaseUtilsIT { List<String> outputs = DatabaseUtils.executeLargeInputs(inputs, input -> { // Check that each partition is only done on 1000 elements max assertThat(input).hasSizeLessThanOrEqualTo(1000); - return input.stream().map(String::valueOf).collect(MoreCollectors.toList()); + return input.stream().map(String::valueOf).collect(Collectors.toList()); }); assertThat(outputs).isEqualTo(expectedOutputs); diff --git a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java index c18d79036aa..6cd5c0f0808 100644 --- a/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java +++ b/server/sonar-db-core/src/testFixtures/java/org/sonar/db/AbstractDbTester.java @@ -44,6 +44,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.apache.commons.dbutils.QueryRunner; @@ -51,7 +52,6 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; import org.junit.rules.ExternalResource; import org.slf4j.LoggerFactory; -import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.collect.Lists.asList; @@ -391,7 +391,7 @@ public class AbstractDbTester<T extends TestDb> extends ExternalResource { columnNames.stream() .sorted(PkColumn.ORDERING_BY_INDEX) .map(PkColumn::getName) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); } } diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java index bcd4c1160d7..0d6947cd48e 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/ce/CeActivityDaoIT.java @@ -30,6 +30,7 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Random; +import java.util.stream.Collectors; import java.util.stream.IntStream; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -43,7 +44,6 @@ import org.junit.runner.RunWith; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.core.util.CloseableIterator; import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.Pagination; @@ -918,7 +918,7 @@ public class CeActivityDaoIT { private List<String> selectPageOfUuids(Pagination pagination) { return underTest.selectByQuery(db.getSession(), new CeTaskQuery(), pagination).stream() .map(CeActivityToUuid.INSTANCE::apply) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private enum CeActivityToUuid implements Function<CeActivityDto, String> { diff --git a/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java b/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java index 15cff865943..294c937a6dc 100644 --- a/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java +++ b/server/sonar-db-dao/src/it/java/org/sonar/db/permission/GroupPermissionDaoIT.java @@ -25,13 +25,13 @@ import java.util.Collections; import java.util.List; import java.util.Random; import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import org.junit.Rule; import org.junit.Test; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbSession; import org.sonar.db.DbTester; import org.sonar.db.audit.NoOpAuditPersister; @@ -1010,7 +1010,7 @@ public class GroupPermissionDaoIT { .stream() .flatMap(map -> map.entrySet().stream()) .map(entry -> (String) entry.getValue()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private ProjectData randomPublicOrPrivateProject() { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java index 425434c6392..c72e72c6347 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/issue/IssueChangeDao.java @@ -23,9 +23,9 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import org.apache.ibatis.session.ResultHandler; import org.sonar.core.issue.FieldDiffs; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -40,7 +40,7 @@ public class IssueChangeDao implements Dao { return selectByTypeAndIssueKeys(session, singletonList(issueKey), IssueChangeDto.TYPE_FIELD_CHANGE) .stream() .map(IssueChangeDto::toFieldDiffs) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public List<IssueChangeDto> selectByTypeAndIssueKeys(DbSession session, Collection<String> issueKeys, String changeType) { diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java index fd90c0a4537..8fd1c9ed34c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/PurgeDao.java @@ -154,7 +154,7 @@ public class PurgeDao implements Dao { return mapper.selectPurgeableAnalyses(componentUuid).stream() .filter(new NewCodePeriodAnalysisFilter(mapper, componentUuid)) .sorted() - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public void purgeCeActivities(DbSession session, PurgeProfiler profiler) { @@ -307,7 +307,7 @@ public class PurgeDao implements Dao { List<String> subviewsOrProjectCopies = nonRootComponents.stream() .filter(PurgeDao::isSubview) .map(ComponentDto::uuid) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); purgeCommands.deleteByRootAndSubviews(subviewsOrProjectCopies); List<String> nonRootComponentUuids = nonRootComponents.stream().map(ComponentDto::uuid).collect(Collectors.toList()); purgeCommands.deleteComponentMeasures(nonRootComponentUuids); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java index d67686ed4c7..358767fbc2c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/purge/period/KeepWithVersionFilter.java @@ -22,9 +22,9 @@ package org.sonar.db.purge.period; import com.google.common.base.Strings; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.DateUtils; import org.slf4j.LoggerFactory; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.purge.PurgeableAnalysisDto; class KeepWithVersionFilter implements Filter { @@ -40,7 +40,7 @@ class KeepWithVersionFilter implements Filter { return history.stream() .filter(analysis -> analysis.getDate().before(before)) .filter(KeepWithVersionFilter::isDeletable) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } @Override diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java index e044ae25e21..4e5e135fa1e 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualitygate/QualityGateGroupPermissionsDao.java @@ -21,6 +21,7 @@ package org.sonar.db.qualitygate; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -31,7 +32,6 @@ import org.sonar.db.user.GroupDto; import org.sonar.db.user.SearchGroupMembershipDto; import org.sonar.db.user.SearchPermissionQuery; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; public class QualityGateGroupPermissionsDao implements Dao { @@ -52,7 +52,7 @@ public class QualityGateGroupPermissionsDao implements Dao { } public boolean exists(DbSession dbSession, QualityGateDto qualityGate, Collection<GroupDto> groups) { - return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), + return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), partition -> mapper(dbSession).selectByQualityGateAndGroups(qualityGate.getUuid(), partition)) .isEmpty(); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java index ce11257b517..fd5f2721fe2 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/ActiveRuleCountQuery.java @@ -20,10 +20,10 @@ package org.sonar.db.qualityprofile; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.rule.RuleStatus; -import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; @@ -34,7 +34,7 @@ public class ActiveRuleCountQuery { private final String inheritance; public ActiveRuleCountQuery(Builder builder) { - this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).collect(MoreCollectors.toList()); + this.profileUuids = builder.profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); this.ruleStatus = builder.ruleStatus; this.inheritance = builder.inheritance; } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java index 580a73241f8..1c2398702c1 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditGroupsDao.java @@ -22,6 +22,7 @@ package org.sonar.db.qualityprofile; import java.util.Collection; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DatabaseUtils; @@ -32,7 +33,6 @@ import org.sonar.db.audit.model.GroupEditorNewValue; import org.sonar.db.user.GroupDto; import org.sonar.db.user.SearchGroupMembershipDto; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; import static org.sonar.db.DatabaseUtils.executeLargeUpdates; @@ -51,7 +51,7 @@ public class QProfileEditGroupsDao implements Dao { } public boolean exists(DbSession dbSession, QProfileDto profile, Collection<GroupDto> groups) { - return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), partition -> mapper(dbSession).selectByQProfileAndGroups(profile.getKee(), partition)) + return !executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), partition -> mapper(dbSession).selectByQProfileAndGroups(profile.getKee(), partition)) .isEmpty(); } @@ -64,7 +64,7 @@ public class QProfileEditGroupsDao implements Dao { } public List<String> selectQProfileUuidsByGroups(DbSession dbSession, Collection<GroupDto> groups) { - return DatabaseUtils.executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(toList()), + return DatabaseUtils.executeLargeInputs(groups.stream().map(GroupDto::getUuid).collect(Collectors.toList()), g -> mapper(dbSession).selectQProfileUuidsByGroups(g)); } @@ -88,7 +88,7 @@ public class QProfileEditGroupsDao implements Dao { int deletedRows = mapper(dbSession).deleteByQProfiles(partitionedProfiles .stream() .map(QProfileDto::getKee) - .collect(toList())); + .collect(Collectors.toList())); if (deletedRows > 0) { partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new GroupEditorNewValue(p))); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java index 437c02d10aa..f96c5d10d55 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QProfileEditUsersDao.java @@ -20,6 +20,7 @@ package org.sonar.db.qualityprofile; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.utils.System2; import org.sonar.db.Dao; import org.sonar.db.DbSession; @@ -29,7 +30,6 @@ import org.sonar.db.audit.model.UserEditorNewValue; import org.sonar.db.user.SearchUserMembershipDto; import org.sonar.db.user.UserDto; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeUpdates; public class QProfileEditUsersDao implements Dao { @@ -78,7 +78,7 @@ public class QProfileEditUsersDao implements Dao { int deletedRows = mapper(dbSession).deleteByQProfiles(partitionedProfiles .stream() .map(QProfileDto::getKee) - .collect(toList())); + .collect(Collectors.toList())); if (deletedRows > 0) { partitionedProfiles.forEach(p -> auditPersister.deleteQualityProfileEditor(dbSession, new UserEditorNewValue(p))); diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java index b3fd50293b5..4fb7dd38f1c 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/qualityprofile/QualityProfileDao.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.utils.System2; @@ -209,7 +210,7 @@ public class QualityProfileDao implements Dao { } public Map<String, Long> countProjectsByProfiles(DbSession dbSession, List<QProfileDto> profiles) { - List<String> profileUuids = profiles.stream().map(QProfileDto::getKee).collect(MoreCollectors.toList()); + List<String> profileUuids = profiles.stream().map(QProfileDto::getKee).collect(Collectors.toList()); return KeyLongValue.toMap(executeLargeInputs(profileUuids, partition -> mapper(dbSession).countProjectsByProfiles(partition))); } diff --git a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java index 589f3655614..c9090eaaebe 100644 --- a/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java +++ b/server/sonar-db-dao/src/main/java/org/sonar/db/user/UserTokenDao.java @@ -25,6 +25,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.core.util.UuidFactory; @@ -33,7 +34,6 @@ import org.sonar.db.DbSession; import org.sonar.db.audit.AuditPersister; import org.sonar.db.audit.model.UserTokenNewValue; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.DatabaseUtils.executeLargeInputs; public class UserTokenDao implements Dao { @@ -82,7 +82,7 @@ public class UserTokenDao implements Dao { public Map<String, Integer> countTokensByUsers(DbSession dbSession, Collection<UserDto> users) { Map<String, Integer> result = new HashMap<>(users.size()); executeLargeInputs( - users.stream().map(UserDto::getUuid).collect(toList()), + users.stream().map(UserDto::getUuid).collect(Collectors.toList()), input -> { List<UserTokenCount> userTokenCounts = mapper(dbSession).countTokensByUserUuids(input); for (UserTokenCount userTokenCount : userTokenCounts) { diff --git a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java index 9fe5a6afc2b..a9b730f4644 100644 --- a/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java +++ b/server/sonar-db-dao/src/test/java/org/sonar/db/DBSessionsImplTest.java @@ -76,7 +76,7 @@ public class DBSessionsImplTest { .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); - assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(MoreCollectors.toList())) + assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(Collectors.toList())) .containsExactly(expected); } @@ -90,7 +90,7 @@ public class DBSessionsImplTest { .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); - assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(MoreCollectors.toList())) + assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(Collectors.toList())) .containsExactly(expected); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java index 9f8d04071b8..4ce51bc9770 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/notification/NotificationDbTester.java @@ -20,8 +20,8 @@ package org.sonar.db.notification; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -49,7 +49,7 @@ public class NotificationDbTester { .setUserUuid(userUuid) .build(), dbSession).stream() .filter(prop -> project == null ? prop.getEntityUuid() == null : prop.getEntityUuid() != null) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); assertThat(result).hasSize(1); assertThat(result.get(0).getValue()).isEqualTo("true"); } diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java index 0fdd3f2365f..7cb8bd12ceb 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/source/FileSourceTester.java @@ -23,10 +23,10 @@ import java.util.Arrays; import java.util.Date; import java.util.Random; import java.util.function.Consumer; +import java.util.stream.Collectors; import java.util.stream.IntStream; import org.apache.commons.lang.math.RandomUtils; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.protobuf.DbFileSources; @@ -49,7 +49,7 @@ public class FileSourceTester { .setFileUuid(file.uuid()) .setSrcHash(randomAlphanumeric(50)) .setDataHash(randomAlphanumeric(50)) - .setLineHashes(IntStream.range(0, new Random().nextInt(21)).mapToObj(String::valueOf).collect(MoreCollectors.toList())) + .setLineHashes(IntStream.range(0, new Random().nextInt(21)).mapToObj(String::valueOf).collect(Collectors.toList())) .setRevision(randomAlphanumeric(100)) .setSourceData(newRandomData(3).build()) .setCreatedAt(new Date().getTime()) @@ -69,7 +69,7 @@ public class FileSourceTester { .setFileUuid(file.uuid()) .setSrcHash(randomAlphanumeric(50)) .setDataHash(randomAlphanumeric(50)) - .setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).collect(MoreCollectors.toList())) + .setLineHashes(IntStream.range(0, numLines).mapToObj(String::valueOf).collect(Collectors.toList())) .setRevision(randomAlphanumeric(100)) .setSourceData(newRandomData(numLines).build()) .setCreatedAt(new Date().getTime()) diff --git a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java index 8b3fb566691..02d0ef9e6a9 100644 --- a/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java +++ b/server/sonar-db-dao/src/testFixtures/java/org/sonar/db/user/UserDbTester.java @@ -24,13 +24,13 @@ import java.util.List; import java.util.Optional; import java.util.Set; import java.util.function.Consumer; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.resources.Qualifiers; import org.sonar.api.security.DefaultGroups; import org.sonar.api.web.UserRole; import org.sonar.core.util.Uuids; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.ce.CeTaskMessageType; @@ -432,7 +432,7 @@ public class UserDbTester { return keys .stream() .map(GlobalPermission::fromKey) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } // USER TOKEN diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java index 4696eeff9d0..2b88dd3fb0e 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/history/MigrationHistoryImpl.java @@ -29,12 +29,12 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import org.sonar.db.Database; import org.sonar.db.DatabaseUtils; import org.sonar.server.platform.db.migration.step.RegisteredMigrationStep; import static com.google.common.base.Preconditions.checkState; -import static org.sonar.core.util.stream.MoreCollectors.toList; public class MigrationHistoryImpl implements MigrationHistory { private static final String SCHEMA_MIGRATIONS_TABLE = "schema_migrations"; @@ -101,7 +101,7 @@ public class MigrationHistoryImpl implements MigrationHistory { } return res.stream() .sorted(Comparator.naturalOrder()) - .collect(toList()); + .collect(Collectors.toList()); } } } diff --git a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java index f30b5066c4b..55a91585073 100644 --- a/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java +++ b/server/sonar-db-migration/src/main/java/org/sonar/server/platform/db/migration/sql/CreateTableBuilder.java @@ -27,9 +27,9 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.CheckForNull; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.dialect.Dialect; import org.sonar.db.dialect.H2; import org.sonar.db.dialect.MsSql; @@ -68,7 +68,7 @@ public class CreateTableBuilder { checkState(!columnDefs.isEmpty() || !pkColumnDefs.isEmpty(), "at least one column must be specified"); return Stream.concat(of(createTableStatement()), createOracleAutoIncrementStatements()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public CreateTableBuilder addColumn(ColumnDef columnDef) { diff --git a/server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java b/server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java index 68b21afdc22..8eaf89f1f2c 100644 --- a/server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java +++ b/server/sonar-main/src/main/java/org/sonar/application/es/EsInstallation.java @@ -26,11 +26,11 @@ import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.Properties; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.sonar.application.command.EsJvmOptions; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.process.Props; import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED; @@ -108,7 +108,7 @@ public class EsInstallation { String dataPath = props.nonNullValue(PATH_DATA.getKey()); return Stream.of("es", "es5", "es6", "es7") .map(t -> new File(dataPath, t)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static File buildDataDir(Props props) { diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java index 76695def76b..884e078b6c0 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/ComponentTextSearchFeatureRepertoire.java @@ -23,12 +23,12 @@ import java.util.List; import java.util.Locale; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.commons.lang.StringUtils; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.MatchQueryBuilder; import org.elasticsearch.index.query.QueryBuilder; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.newindex.DefaultIndexSettings; import org.sonar.server.es.newindex.DefaultIndexSettingsElement; import org.sonar.server.es.textsearch.ComponentTextSearchQueryFactory.ComponentTextSearchQuery; @@ -71,7 +71,7 @@ public enum ComponentTextSearchFeatureRepertoire implements ComponentTextSearchF if (tokens.isEmpty()) { return Stream.empty(); } - List<String> lowerCaseTokens = tokens.stream().map(t -> t.toLowerCase(Locale.ENGLISH)).collect(MoreCollectors.toList()); + List<String> lowerCaseTokens = tokens.stream().map(t -> t.toLowerCase(Locale.ENGLISH)).collect(Collectors.toList()); BoolQueryBuilder queryBuilder = prefixAndPartialQuery(lowerCaseTokens, query.getFieldName(), SEARCH_PREFIX_CASE_INSENSITIVE_ANALYZER) .boost(2F); return Stream.of(queryBuilder); diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/JavaTokenizer.java b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/JavaTokenizer.java index 8608b1e7fd4..c768f273364 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/JavaTokenizer.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/es/textsearch/JavaTokenizer.java @@ -21,8 +21,8 @@ package org.sonar.server.es.textsearch; import java.util.Arrays; import java.util.List; +import java.util.stream.Collectors; import org.apache.commons.lang.StringUtils; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.newindex.DefaultIndexSettings; import static org.sonar.server.es.newindex.DefaultIndexSettings.MINIMUM_NGRAM_LENGTH; @@ -41,6 +41,6 @@ public class JavaTokenizer { queryText.split(DefaultIndexSettings.SEARCH_TERM_TOKENIZER_PATTERN)) .filter(StringUtils::isNotEmpty) .filter(s -> s.length() >= MINIMUM_NGRAM_LENGTH) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java index a63ebea4cc8..8ad8c6f080e 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/measure/index/ProjectMeasuresDoc.java @@ -25,9 +25,9 @@ import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.BaseDoc; import org.sonar.server.permission.index.AuthorizationDoc; @@ -121,7 +121,7 @@ public class ProjectMeasuresDoc extends BaseDoc { .map(entry -> ImmutableMap.<String, Object>of( SUB_FIELD_MEASURES_KEY, entry.getKey(), SUB_FIELD_MEASURES_VALUE, entry.getValue())) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); return this; } @@ -145,7 +145,7 @@ public class ProjectMeasuresDoc extends BaseDoc { .map(entry -> ImmutableMap.<String, Object>of( SUB_FIELD_DISTRIB_LANGUAGE, entry.getKey(), SUB_FIELD_DISTRIB_NCLOC, entry.getValue())) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); return this; } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java index 2fff25c259e..85cadce0d8b 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/rule/index/RuleIndex.java @@ -28,6 +28,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.function.Function; +import java.util.stream.Collectors; import javax.annotation.Nullable; import org.apache.commons.lang.StringUtils; import org.apache.lucene.search.join.ScoreMode; @@ -54,7 +55,6 @@ import org.sonar.api.rule.RuleStatus; import org.sonar.api.rule.Severity; import org.sonar.api.rules.RuleType; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.qualityprofile.QProfileDto; import org.sonar.server.es.EsClient; import org.sonar.server.es.EsUtils; @@ -142,7 +142,7 @@ public class RuleIndex { public static final List<String> ALL_STATUSES_EXCEPT_REMOVED = Arrays.stream(RuleStatus.values()) .filter(status -> !RuleStatus.REMOVED.equals(status)) .map(RuleStatus::toString) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); private static final String AGGREGATION_NAME_FOR_TAGS = "tagsAggregation"; @@ -290,7 +290,7 @@ public class RuleIndex { Collection<RuleType> types = query.getTypes(); if (isNotEmpty(types)) { - List<String> typeNames = types.stream().map(RuleType::toString).collect(MoreCollectors.toList()); + List<String> typeNames = types.stream().map(RuleType::toString).collect(Collectors.toList()); filters.put(FIELD_RULE_TYPE, QueryBuilders.termsQuery(FIELD_RULE_TYPE, typeNames)); } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/security/SecurityStandards.java b/server/sonar-server-common/src/main/java/org/sonar/server/security/SecurityStandards.java index 1ab2cdda6c7..16377c9201b 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/security/SecurityStandards.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/security/SecurityStandards.java @@ -41,7 +41,6 @@ import static java.util.Arrays.stream; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; import static org.sonar.api.server.rule.RulesDefinition.PciDssVersion.V3_2; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.security.SecurityStandards.VulnerabilityProbability.HIGH; @@ -394,7 +393,7 @@ public final class SecurityStandards { .stream() .filter(k -> cwe.stream().anyMatch(CWES_BY_SQ_CATEGORY.get(k)::contains)) .sorted(SQ_CATEGORY_ORDERING) - .collect(toList()); + .collect(Collectors.toList()); return result.isEmpty() ? singletonList(SQCategory.OTHERS) : result; } diff --git a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebHooksImpl.java b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebHooksImpl.java index b62a495ad97..49a5317af00 100644 --- a/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebHooksImpl.java +++ b/server/sonar-server-common/src/main/java/org/sonar/server/webhook/WebHooksImpl.java @@ -22,6 +22,7 @@ package org.sonar.server.webhook; import java.util.List; import java.util.Optional; import java.util.function.Supplier; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -30,7 +31,6 @@ import org.sonar.api.ce.posttask.PostProjectAnalysisTask; import org.sonar.api.server.ServerSide; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.project.ProjectDto; @@ -106,7 +106,7 @@ public class WebHooksImpl implements WebHooks { List<Webhook> webhooks = readWebHooksFrom(analysis.projectUuid(), taskLogStatistics) .map(dto -> new Webhook(dto.getUuid(), analysis.projectUuid(), analysis.ceTaskUuid(), analysis.analysisUuid(), dto.getName(), dto.getUrl(), dto.getSecret())) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); if (webhooks.isEmpty()) { return; } diff --git a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowForSecurityHotspotsTest.java b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowForSecurityHotspotsTest.java index ca91823fd30..f075779be84 100644 --- a/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowForSecurityHotspotsTest.java +++ b/server/sonar-server-common/src/test/java/org/sonar/server/issue/workflow/IssueWorkflowForSecurityHotspotsTest.java @@ -26,6 +26,7 @@ import java.util.Calendar; import java.util.Collection; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.Nullable; import org.apache.commons.lang.time.DateUtils; @@ -36,7 +37,6 @@ import org.sonar.api.rule.RuleKey; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.FieldDiffs; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.issue.IssueFieldsSetter; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; @@ -293,7 +293,7 @@ public class IssueWorkflowForSecurityHotspotsTest { } private Collection<String> keys(List<Transition> transitions) { - return transitions.stream().map(Transition::key).collect(MoreCollectors.toList()); + return transitions.stream().map(Transition::key).collect(Collectors.toList()); } private static void setStatusPreviousToClosed(DefaultIssue hotspot, String previousStatus, @Nullable String previousResolution, @Nullable String newResolution) { diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginDownloader.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginDownloader.java index cb35d124d5a..755c8d920b5 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginDownloader.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginDownloader.java @@ -27,13 +27,13 @@ import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; import org.sonar.api.Startable; import org.sonar.api.utils.HttpDownloader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.core.platform.PluginInfo; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.platform.ServerFileSystem; import org.sonar.updatecenter.common.Release; import org.sonar.updatecenter.common.UpdateCenter; @@ -105,7 +105,7 @@ public class PluginDownloader implements Startable { return listPlugins(this.downloadDir) .stream() .map(PluginInfo::create) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public void download(String pluginKey, Version version) { diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginUninstaller.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginUninstaller.java index f265b9017da..6e6725126f4 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginUninstaller.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/plugins/PluginUninstaller.java @@ -25,12 +25,12 @@ import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import java.util.stream.Collectors; import org.apache.commons.io.FileUtils; import org.sonar.api.Startable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.sonar.core.platform.PluginInfo; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.platform.ServerFileSystem; import static java.lang.String.format; @@ -99,7 +99,7 @@ public class PluginUninstaller implements Startable { public Collection<PluginInfo> getUninstalledPlugins() { return listJarFiles(fs.getUninstalledPluginsDir()).stream() .map(PluginInfo::create) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static Collection<File> listJarFiles(File dir) { diff --git a/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/CachingRuleFinder.java b/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/CachingRuleFinder.java index c6d11b7b06b..370b7aa8be9 100644 --- a/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/CachingRuleFinder.java +++ b/server/sonar-webserver-api/src/main/java/org/sonar/server/rule/CachingRuleFinder.java @@ -37,7 +37,6 @@ import org.sonar.api.rules.Rule; import org.sonar.api.rules.RuleFinder; import org.sonar.api.rules.RulePriority; import org.sonar.api.rules.RuleQuery; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.rule.RuleDto; @@ -126,7 +125,7 @@ public class CachingRuleFinder implements ServerRuleFinder { .filter(entry -> matchQuery(entry.getKey(), query)) .sorted(FIND_BY_QUERY_ORDER) .map(Map.Entry::getValue) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static boolean matchQuery(RuleDto ruleDto, RuleQuery ruleQuery) { diff --git a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java index 3ae3c804e8d..041a1f6cc33 100644 --- a/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java +++ b/server/sonar-webserver-auth/src/main/java/org/sonar/server/user/AbstractUserSession.java @@ -23,10 +23,10 @@ import java.util.Collection; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.ComponentDto; import org.sonar.db.entity.EntityDto; import org.sonar.db.permission.GlobalPermission; @@ -164,7 +164,7 @@ public abstract class AbstractUserSession implements UserSession { boolean allowPublicComponent = PUBLIC_PERMISSIONS.contains(permission); return components.stream() .filter(c -> (allowPublicComponent && !c.isPrivate()) || hasComponentPermission(permission, c)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } @Override diff --git a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java index 5ce4baa4475..23e077a5764 100644 --- a/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java +++ b/server/sonar-webserver-core/src/main/java/org/sonar/server/rule/RegisterRules.java @@ -77,7 +77,6 @@ import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.unmodifiableMap; import static org.apache.commons.lang.StringUtils.isNotEmpty; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; @@ -639,7 +638,7 @@ public class RegisterRules implements Startable { // DeprecatedKeys that must be deleted List<String> uuidsToBeDeleted = difference(deprecatedRuleKeysFromDB, deprecatedRuleKeysFromDefinition).stream() .map(SingleDeprecatedRuleKey::getUuid) - .collect(toList()); + .collect(Collectors.toList()); dbClient.ruleDao().deleteDeprecatedRuleKeys(dbSession, uuidsToBeDeleted); @@ -824,7 +823,7 @@ public class RegisterRules implements Startable { private static void verifyRuleKeyConsistency(List<RulesDefinition.Repository> repositories, RegisterRulesContext registerRulesContext) { List<RulesDefinition.Rule> definedRules = repositories.stream() .flatMap(r -> r.rules().stream()) - .collect(toList()); + .collect(Collectors.toList()); Set<RuleKey> definedRuleKeys = definedRules.stream() .map(r -> RuleKey.of(r.repository().key(), r.key())) @@ -832,7 +831,7 @@ public class RegisterRules implements Startable { List<RuleKey> definedDeprecatedRuleKeys = definedRules.stream() .flatMap(r -> r.deprecatedRuleKeys().stream()) - .collect(toList()); + .collect(Collectors.toList()); // Find duplicates in declared deprecated rule keys Set<RuleKey> duplicates = findDuplicates(definedDeprecatedRuleKeys); diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java index e967e9db067..8832c898f19 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueIndex.java @@ -1176,21 +1176,21 @@ public class IssueIndex { return getSearchResponse(sourceBuilder) .getAggregations().asList().stream() .map(c -> processSecurityReportIssueSearchResultsWithLevelDistribution((ParsedFilter) c, version, level)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private List<SecurityStandardCategoryStatistics> searchWithDistribution(SearchSourceBuilder sourceBuilder, String version, @Nullable Integer level) { return getSearchResponse(sourceBuilder) .getAggregations().asList().stream() .map(c -> processSecurityReportIssueSearchResultsWithDistribution((ParsedFilter) c, version, level)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private List<SecurityStandardCategoryStatistics> search(SearchSourceBuilder sourceBuilder, boolean includeDistribution, @Nullable String version) { return getSearchResponse(sourceBuilder) .getAggregations().asList().stream() .map(c -> processSecurityReportIssueSearchResults((ParsedFilter) c, includeDistribution, version)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private SearchResponse getSearchResponse(SearchSourceBuilder sourceBuilder) { diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 1047ca022c6..92543babeec 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -74,7 +74,6 @@ import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime; import static org.sonar.api.web.UserRole.USER; import static org.sonar.core.util.stream.MoreCollectors.toHashSet; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.newcodeperiod.NewCodePeriodType.REFERENCE_BRANCH; @@ -279,7 +278,7 @@ public class IssueQueryFactory { SearchRequest request) { builder.onComponentOnly(onComponentOnly); if (onComponentOnly) { - builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(toList())); + builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(Collectors.toList())); setBranch(builder, components.get(0), request.getBranch(), request.getPullRequest(), session); return; } @@ -334,7 +333,7 @@ public class IssueQueryFactory { addDirectories(builder, components); break; case Qualifiers.FILE, Qualifiers.UNIT_TEST_FILE: - builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(toList())); + builder.componentUuids(components.stream().map(ComponentDto::uuid).collect(Collectors.toList())); break; default: throw new IllegalArgumentException("Unable to set search root context for components " + Joiner.on(',').join(components)); diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java index e077ea99664..7873966b489 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/measure/index/ProjectMeasuresIndex.java @@ -29,6 +29,7 @@ import java.util.Objects; import java.util.Set; import java.util.function.Consumer; import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -484,7 +485,7 @@ public class ProjectMeasuresIndex { return aggregation.getBuckets().stream() .skip((page-1) * size) .map(Bucket::getKeyAsString) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private interface FacetBuilder { diff --git a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java index 01830e1bd25..bc06a3f88a6 100644 --- a/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java +++ b/server/sonar-webserver-es/src/test/java/org/sonar/server/permission/index/FooIndex.java @@ -21,11 +21,10 @@ package org.sonar.server.permission.index; import java.util.Arrays; import java.util.List; -import org.elasticsearch.action.search.SearchRequest; +import java.util.stream.Collectors; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.SearchHits; import org.elasticsearch.search.builder.SearchSourceBuilder; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.es.EsClient; import static org.sonar.server.permission.index.FooIndexDefinition.DESCRIPTOR; @@ -48,7 +47,7 @@ public class FooIndex { .getHits(); List<String> names = Arrays.stream(hits.getHits()) .map(h -> h.getSourceAsMap().get(FooIndexDefinition.FIELD_NAME).toString()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); return names.size() == 2 && names.contains("bar") && names.contains("baz"); } } diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java index 586c78b23ef..8afb67c7946 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SearchProjectsActionIT.java @@ -28,6 +28,7 @@ import java.util.Date; import java.util.List; import java.util.Optional; import java.util.function.Consumer; +import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; import javax.annotation.Nullable; @@ -98,7 +99,6 @@ import static org.sonar.api.server.ws.WebService.Param.PAGE; import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; import static org.sonar.api.server.ws.WebService.Param.SORT; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_002; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_003; @@ -189,7 +189,7 @@ public class SearchProjectsActionIT { assertThat(def.isInternal()).isTrue(); assertThat(def.isPost()).isFalse(); assertThat(def.responseExampleAsString()).isNotEmpty(); - assertThat(def.params().stream().map(Param::key).collect(toList())).containsOnly("filter", "facets", "s", "asc", "ps", "p", "f"); + assertThat(def.params().stream().map(Param::key).collect(Collectors.toList())).containsOnly("filter", "facets", "s", "asc", "ps", "p", "f"); assertThat(def.changelog()).hasSize(2); Param sort = def.param("s"); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java index 17dc94f5a5f..9d4bd305bb4 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/component/ws/SuggestionsActionIT.java @@ -30,7 +30,6 @@ import org.sonar.api.resources.Qualifiers; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.ComponentTesting; @@ -79,7 +78,7 @@ import static org.sonar.test.JsonAssert.assertJson; public class SuggestionsActionIT { private static final String[] SUGGESTION_QUALIFIERS = Stream.of(SuggestionCategory.values()) .map(SuggestionCategory::getQualifier) - .collect(MoreCollectors.toList()).toArray(new String[0]); + .collect(Collectors.toList()).toArray(new String[0]); @Rule public final DbTester db = DbTester.create(System2.INSTANCE); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java index f84732cc2d5..cc31c1a7f18 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/ComponentTreeActionIT.java @@ -21,6 +21,7 @@ package org.sonar.server.measure.ws; import com.google.common.base.Joiner; import java.util.List; +import java.util.stream.Collectors; import java.util.stream.IntStream; import org.junit.Rule; import org.junit.Test; @@ -31,7 +32,6 @@ import org.sonar.api.resources.ResourceTypes; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.core.component.DefaultResourceTypes; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -890,7 +890,7 @@ public class ComponentTreeActionIT { db.components().insertSnapshot(mainBranch); List<String> metrics = IntStream.range(0, 20) .mapToObj(i -> "metric" + i) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); db.commit(); assertThatThrownBy(() -> { diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchHistoryActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchHistoryActionIT.java index d4baa160954..26c8891b32a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchHistoryActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/measure/ws/SearchHistoryActionIT.java @@ -20,6 +20,7 @@ package org.sonar.server.measure.ws; import java.util.List; +import java.util.stream.Collectors; import java.util.stream.LongStream; import org.junit.Before; import org.junit.Rule; @@ -29,7 +30,6 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.server.ws.WebService.Param; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.DbTester; @@ -208,7 +208,7 @@ public class SearchHistoryActionIT { .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(i * 1_000_000_000))) .peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(101d))) .map(a -> formatDateTime(a.getCreatedAt())) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); db.commit(); SearchHistoryRequest request = SearchHistoryRequest.builder() @@ -232,7 +232,7 @@ public class SearchHistoryActionIT { .mapToObj(i -> dbClient.snapshotDao().insert(dbSession, newAnalysis(project).setCreatedAt(System2.INSTANCE.now() + i * 1_000_000_000L))) .peek(a -> dbClient.measureDao().insert(dbSession, newMeasureDto(complexityMetric, project, a).setValue(Double.valueOf(a.getCreatedAt())))) .map(a -> formatDateTime(a.getCreatedAt())) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); db.commit(); SearchHistoryRequest request = SearchHistoryRequest.builder() diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java index bb1fa77deb0..cf6c4a0ab1a 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/qualityprofile/ws/SearchActionIT.java @@ -20,6 +20,7 @@ package org.sonar.server.qualityprofile.ws; import java.util.List; +import java.util.stream.Collectors; import org.junit.Rule; import org.junit.Test; import org.sonar.api.resources.Language; @@ -28,7 +29,6 @@ import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.DateUtils; import org.sonar.api.utils.System2; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbTester; import org.sonar.db.permission.GlobalPermission; @@ -366,10 +366,10 @@ public class SearchActionIT { db.qualityProfiles().setAsDefault(sonarWayCs, myCompanyProfile, sonarWayPython); // rules List<RuleDto> javaRules = range(0, 10).mapToObj(i -> db.rules().insertRule(r -> r.setLanguage(java.getKey()))) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); List<RuleDto> deprecatedJavaRules = range(0, 5) .mapToObj(i -> db.rules().insertRule(r -> r.setLanguage(java.getKey()).setStatus(DEPRECATED))) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); range(0, 7).forEach(i -> db.qualityProfiles().activateRule(myCompanyProfile, javaRules.get(i))); range(0, 2).forEach(i -> db.qualityProfiles().activateRule(myCompanyProfile, deprecatedJavaRules.get(i))); range(0, 10).forEach(i -> db.qualityProfiles().activateRule(myBuProfile, javaRules.get(i))); diff --git a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java index 0e6a06f7971..a0535676c65 100644 --- a/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java +++ b/server/sonar-webserver-webapi/src/it/java/org/sonar/server/rule/ws/SearchActionIT.java @@ -44,7 +44,6 @@ import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.System2; import org.sonar.core.util.UuidFactory; import org.sonar.core.util.UuidFactoryFast; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbTester; import org.sonar.db.qualityprofile.ActiveRuleParamDto; import org.sonar.db.qualityprofile.QProfileDto; @@ -1064,7 +1063,7 @@ public class SearchActionIT { assertThat(response.getP()).isOne(); assertThat(response.getPaging().getPageIndex()).isOne(); assertThat(response.getPaging().getPageSize()).isNotZero(); - RuleKey[] expectedRuleKeys = stream(expectedRules).map(RuleDto::getKey).collect(MoreCollectors.toList()).toArray(new RuleKey[0]); + RuleKey[] expectedRuleKeys = stream(expectedRules).map(RuleDto::getKey).collect(Collectors.toList()).toArray(new RuleKey[0]); assertThat(response.getRulesList()) .extracting(r -> RuleKey.parse(r.getKey())) .containsExactlyInAnyOrder(expectedRuleKeys); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java index df525437848..8729ca4a866 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/branch/ws/ListAction.java @@ -23,6 +23,7 @@ import com.google.common.io.Resources; import java.util.Collection; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import javax.annotation.Nullable; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; @@ -46,7 +47,6 @@ import static java.util.Optional.ofNullable; import static org.sonar.api.measures.CoreMetrics.ALERT_STATUS_KEY; import static org.sonar.api.utils.DateUtils.formatDateTime; import static org.sonar.api.web.UserRole.USER; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.component.BranchType.BRANCH; import static org.sonar.db.permission.GlobalPermission.SCAN; @@ -89,8 +89,8 @@ public class ListAction implements BranchWsAction { Collection<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, projectOrApp).stream() .filter(b -> b.getBranchType() == BRANCH) - .collect(toList()); - List<String> branchUuids = branches.stream().map(BranchDto::getUuid).collect(toList()); + .collect(Collectors.toList()); + List<String> branchUuids = branches.stream().map(BranchDto::getUuid).collect(Collectors.toList()); Map<String, LiveMeasureDto> qualityGateMeasuresByComponentUuids = dbClient.liveMeasureDao() .selectByComponentUuidsAndMetricKeys(dbSession, branchUuids, singletonList(ALERT_STATUS_KEY)).stream() diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java index d5040db7d5b..5e759d4897c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ce/ws/ActivityAction.java @@ -27,6 +27,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import java.util.stream.StreamSupport; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -64,7 +65,6 @@ import static java.util.stream.Collectors.toSet; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.Pagination.forPage; import static org.sonar.server.ce.ws.CeWsParameters.PARAM_COMPONENT; import static org.sonar.server.ce.ws.CeWsParameters.PARAM_MAX_EXECUTED_AT; @@ -289,7 +289,7 @@ public class ActivityAction implements CeWsAction { } else if (componentQuery != null) { query.setEntityUuids(loadEntities(dbSession, componentQuery).stream() .map(EntityDto::getUuid) - .collect(toList())); + .collect(Collectors.toList())); } return query; } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/FilterParser.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/FilterParser.java index 90b08fcb00a..e3179cb62e7 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/FilterParser.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/FilterParser.java @@ -25,11 +25,11 @@ import java.util.List; import java.util.Optional; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import java.util.stream.Stream; import java.util.stream.StreamSupport; import javax.annotation.CheckForNull; import javax.annotation.Nullable; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.measure.index.ProjectMeasuresQuery; import static com.google.common.base.Strings.isNullOrEmpty; @@ -51,7 +51,7 @@ public class FilterParser { public static List<Criterion> parse(String filter) { return StreamSupport.stream(CRITERIA_SPLITTER.split(filter).spliterator(), false) .map(FilterParser::parseCriterion) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static Criterion parseCriterion(String rawCriterion) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java index 7c51d7c3b2e..6065459aa92 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/SuggestionsAction.java @@ -61,7 +61,6 @@ import static java.util.Collections.emptyList; import static java.util.Collections.emptySet; import static java.util.Collections.singletonList; import static org.sonar.api.web.UserRole.USER; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.server.component.index.SuggestionQuery.DEFAULT_LIMIT; import static org.sonar.server.es.newindex.DefaultIndexSettings.MINIMUM_NGRAM_LENGTH; @@ -289,14 +288,14 @@ public class SuggestionsAction implements ComponentsWsAction { .map(hit -> toSuggestion(hit, recentlyBrowsedKeys, favoriteUuids, entitiesByUuids)) .filter(Optional::isPresent) .map(Optional::get) - .collect(toList()); + .collect(Collectors.toList()); return Category.newBuilder() .setQ(qualifier.getQualifier()) .setMore(Math.max(0, qualifier.getTotalHits() - coveredItems)) .addAllItems(suggestions) .build(); - }).collect(toList()); + }).collect(Collectors.toList()); } /** diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java index 827be3accba..dadcc044b55 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/component/ws/TreeAction.java @@ -59,7 +59,6 @@ import static java.lang.String.CASE_INSENSITIVE_ORDER; import static java.lang.String.format; import static java.util.Collections.emptyMap; import static org.sonar.api.utils.Paging.offset; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.component.ComponentTreeQuery.Strategy.CHILDREN; import static org.sonar.db.component.ComponentTreeQuery.Strategy.LEAVES; import static org.sonar.server.component.ws.ComponentDtoToWsComponent.componentDtoToWsComponent; @@ -206,7 +205,7 @@ public class TreeAction implements ComponentsWsAction { List<String> referenceComponentIds = components.stream() .map(ComponentDto::getCopyComponentUuid) .filter(Objects::nonNull) - .collect(toList()); + .collect(Collectors.toList()); if (referenceComponentIds.isEmpty()) { return emptyMap(); } @@ -324,7 +323,7 @@ public class TreeAction implements ComponentsWsAction { private static List<ComponentDto> paginateComponents(List<ComponentDto> components, Request wsRequest) { return components.stream().skip(offset(wsRequest.getPage(), wsRequest.getPageSize())) - .limit(wsRequest.getPageSize()).collect(toList()); + .limit(wsRequest.getPageSize()).collect(Collectors.toList()); } private static List<ComponentDto> sortComponents(List<ComponentDto> components, Request wsRequest) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/developers/ws/SearchEventsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/developers/ws/SearchEventsAction.java index 3872dc400c6..534fa8f4696 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/developers/ws/SearchEventsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/developers/ws/SearchEventsAction.java @@ -58,7 +58,6 @@ import static java.nio.charset.StandardCharsets.UTF_8; import static java.util.Comparator.comparing; import static org.sonar.api.utils.DateUtils.formatDateTime; import static org.sonar.api.utils.DateUtils.parseDateTimeQuietly; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.component.BranchType.BRANCH; import static org.sonar.db.component.BranchType.PULL_REQUEST; @@ -141,7 +140,7 @@ public class SearchEventsAction implements DevelopersWsAction { return Stream.empty(); } - List<String> branchUuids = analyses.stream().map(SnapshotDto::getRootComponentUuid).collect(toList()); + List<String> branchUuids = analyses.stream().map(SnapshotDto::getRootComponentUuid).collect(Collectors.toList()); Map<String, BranchDto> branchesByUuids = dbClient.branchDao().selectByUuids(dbSession, branchUuids).stream().collect(uniqueIndex(BranchDto::getUuid)); return Stream.concat( @@ -240,7 +239,7 @@ public class SearchEventsAction implements DevelopersWsAction { checkArgument(date != null, "'%s' cannot be parsed as either a date or date+time", stringDate); return date.getTime() + 1_000L; }) - .collect(toList()); + .collect(Collectors.toList()); } private static String encode(String text) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/SearchAction.java index 8344bba9755..c14a10e703f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/favorite/ws/SearchAction.java @@ -20,13 +20,13 @@ package org.sonar.server.favorite.ws; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Request; 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.Paging; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.entity.EntityDto; import org.sonar.server.favorite.FavoriteFinder; import org.sonar.server.user.UserSession; @@ -83,7 +83,7 @@ public class SearchAction implements FavoritesWsAction { List<EntityDto> displayedFavorites = authorizedFavorites.stream() .skip(paging.offset()) .limit(paging.pageSize()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); return new SearchResults(paging, displayedFavorites); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssueChangeWSSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssueChangeWSSupport.java index 72b91574ecb..a2182e03d35 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssueChangeWSSupport.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/IssueChangeWSSupport.java @@ -55,7 +55,6 @@ import static java.util.Collections.emptyMap; import static java.util.Optional.empty; import static java.util.Optional.ofNullable; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.issue.IssueChangeDto.TYPE_COMMENT; @@ -115,10 +114,10 @@ public class IssueChangeWSSupport { List<IssueChangeDto> all = dbClient.issueChangeDao().selectByIssueKeys(dbSession, issueKeys); changes = all.stream() .filter(t -> TYPE_FIELD_CHANGE.equals(t.getChangeType())) - .collect(toList()); + .collect(Collectors.toList()); comments = all.stream() .filter(t -> TYPE_COMMENT.equals(t.getChangeType())) - .collect(toList()); + .collect(Collectors.toList()); break; default: throw new IllegalStateException("Unsupported Load value:" + load); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/TransitionService.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/TransitionService.java index 8da80a3e604..4f3e4eb4c29 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/TransitionService.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/TransitionService.java @@ -21,9 +21,9 @@ package org.sonar.server.issue; import java.util.Collections; import java.util.List; +import java.util.stream.Collectors; import org.sonar.core.issue.DefaultIssue; import org.sonar.core.issue.IssueChangeContext; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.issue.workflow.IssueWorkflow; import org.sonar.server.issue.workflow.Transition; import org.sonar.server.user.UserSession; @@ -55,7 +55,7 @@ public class TransitionService { .stream() .filter(transition -> (userSession.isLoggedIn() && isBlank(transition.requiredProjectPermission())) || userSession.hasComponentUuidPermission(transition.requiredProjectPermission(), projectUuid)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } public boolean doTransition(DefaultIssue defaultIssue, IssueChangeContext issueChangeContext, String transitionKey) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java index ca3ecb2fe7a..d51fba13081 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/issue/ws/BulkChangeAction.java @@ -212,7 +212,7 @@ public class BulkChangeAction implements IssuesWsAction { List<DefaultIssue> items = bulkChangeData.issues.stream() .filter(bulkChange(issueChangeContext, bulkChangeData, result)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); issueStorage.save(dbSession, items); refreshLiveMeasures(dbSession, bulkChangeData, result); @@ -239,7 +239,7 @@ public class BulkChangeAction implements IssuesWsAction { .map(data.componentsByUuid::get) .collect(Collectors.toList()); - List<DefaultIssue> changedIssues = data.issues.stream().filter(result.success::contains).collect(MoreCollectors.toList()); + List<DefaultIssue> changedIssues = data.issues.stream().filter(result.success::contains).collect(Collectors.toList()); issueChangePostProcessor.process(dbSession, changedIssues, touchedComponents, false); } @@ -401,7 +401,7 @@ public class BulkChangeAction implements IssuesWsAction { this.availableActions = actions.stream() .filter(action -> propertiesByActions.containsKey(action.key())) .filter(action -> action.verify(getProperties(action.key()), issues, userSession)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private List<ComponentDto> getComponents(DbSession dbSession, Collection<String> componentUuids) { @@ -417,7 +417,7 @@ public class BulkChangeAction implements IssuesWsAction { return allIssues.stream() .filter(issue -> branchUuids.contains(issue.getProjectUuid())) .map(IssueDto::toDefaultIssue) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } Map<String, Object> getProperties(String actionKey) { @@ -425,7 +425,7 @@ public class BulkChangeAction implements IssuesWsAction { } List<Action> getActionsWithoutComment() { - return availableActions.stream().filter(action -> !action.key().equals(COMMENT_KEY)).collect(MoreCollectors.toList()); + return availableActions.stream().filter(action -> !action.key().equals(COMMENT_KEY)).collect(Collectors.toList()); } Optional<Action> getCommentAction() { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java index c7986f064a1..efbdf73f508 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchAction.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -50,7 +51,6 @@ import static org.sonar.api.resources.Qualifiers.APP; import static org.sonar.api.resources.Qualifiers.PROJECT; import static org.sonar.api.resources.Qualifiers.SUBVIEW; import static org.sonar.api.resources.Qualifiers.VIEW; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.measure.ws.MeasureDtoToWsMeasure.updateMeasureBuilder; import static org.sonar.server.measure.ws.MeasuresWsParametersBuilder.createMetricKeysParameter; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; @@ -153,7 +153,7 @@ public class SearchAction implements MeasuresWsAction { private List<MetricDto> searchMetrics() { List<MetricDto> dbMetrics = dbClient.metricDao().selectByKeys(dbSession, request.getMetricKeys()); - List<String> metricKeys = dbMetrics.stream().map(MetricDto::getKey).collect(toList()); + List<String> metricKeys = dbMetrics.stream().map(MetricDto::getKey).collect(Collectors.toList()); checkRequest(request.getMetricKeys().size() == dbMetrics.size(), "The following metrics are not found: %s", String.join(", ", difference(request.getMetricKeys(), metricKeys))); return dbMetrics; @@ -165,7 +165,7 @@ public class SearchAction implements MeasuresWsAction { return expected.stream() .filter(value -> !actualSet.contains(value)) .sorted(String::compareTo) - .collect(toList()); + .collect(Collectors.toList()); } private List<LiveMeasureDto> searchMeasures() { @@ -200,7 +200,7 @@ public class SearchAction implements MeasuresWsAction { return measure; }) .sorted(comparing(byMetricKey).thenComparing(byComponentName)) - .collect(toList()); + .collect(Collectors.toList()); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java index c911ffdd1c4..da2c8846683 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryAction.java @@ -24,6 +24,7 @@ import java.util.Date; import java.util.List; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; import java.util.stream.Stream; import javax.annotation.CheckForNull; import javax.annotation.Nullable; @@ -185,7 +186,7 @@ public class SearchHistoryAction implements MeasuresWsAction { Date to = parseEndingDateOrDateTime(request.getTo()); PastMeasureQuery dbQuery = new PastMeasureQuery( result.getComponent().uuid(), - result.getMetrics().stream().map(MetricDto::getUuid).collect(MoreCollectors.toList()), + result.getMetrics().stream().map(MetricDto::getUuid).collect(Collectors.toList()), from == null ? null : from.getTime(), to == null ? null : (to.getTime() + 1_000L)); return dbClient.measureDao().selectPastMeasures(dbSession, dbQuery); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java index 32cdc832733..084ed09ab31 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/measure/ws/SearchHistoryResult.java @@ -25,6 +25,7 @@ import com.google.common.collect.Table; import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.component.ComponentDto; import org.sonar.db.component.SnapshotDto; @@ -68,7 +69,7 @@ public class SearchHistoryResult { public SearchHistoryResult setAnalyses(List<SnapshotDto> analyses) { this.paging = Common.Paging.newBuilder().setPageIndex(page).setPageSize(pageSize).setTotal(analyses.size()).build(); - this.analyses = analyses.stream().skip(offset(page, pageSize)).limit(pageSize).collect(MoreCollectors.toList()); + this.analyses = analyses.stream().skip(offset(page, pageSize)).limit(pageSize).collect(Collectors.toList()); return this; } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java index af98e238fe1..8733c4f036a 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/newcodeperiod/ws/ListAction.java @@ -46,7 +46,6 @@ import org.sonar.server.user.UserSession; import org.sonarqube.ws.NewCodePeriods; import org.sonarqube.ws.NewCodePeriods.ListWSResponse; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.ws.WsUtils.createHtmlExternalLink; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.NewCodePeriods.ShowWSResponse.newBuilder; @@ -94,7 +93,7 @@ public class ListAction implements NewCodePeriodsWsAction { Collection<BranchDto> branches = dbClient.branchDao().selectByProject(dbSession, project).stream() .filter(b -> b.getBranchType() == BranchType.BRANCH) .sorted(Comparator.comparing(BranchDto::getKey)) - .collect(toList()); + .collect(Collectors.toList()); List<NewCodePeriodDto> newCodePeriods = newCodePeriodDao.selectAllByProject(dbSession, project.getUuid()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java index d1aa2f0a1f1..0d86b331e3f 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/DispatchersImpl.java @@ -20,9 +20,9 @@ package org.sonar.server.notification.ws; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.Startable; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.notification.NotificationDispatcherMetadata.GLOBAL_NOTIFICATION; import static org.sonar.server.notification.NotificationDispatcherMetadata.PER_PROJECT_NOTIFICATION; @@ -52,11 +52,11 @@ public class DispatchersImpl implements Dispatchers, Startable { this.globalDispatchers = notificationCenter.getDispatcherKeysForProperty(GLOBAL_NOTIFICATION, "true") .stream() .sorted() - .collect(toList()); + .collect(Collectors.toList()); this.projectDispatchers = notificationCenter.getDispatcherKeysForProperty(PER_PROJECT_NOTIFICATION, "true") .stream() .sorted() - .collect(toList()); + .collect(Collectors.toList()); } @Override diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java index 08d727975c9..962ca757d77 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/ListAction.java @@ -27,6 +27,7 @@ import java.util.Set; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.UnaryOperator; +import java.util.stream.Collectors; import java.util.stream.Stream; import org.sonar.api.notifications.NotificationChannel; import org.sonar.api.server.ws.Request; @@ -67,7 +68,7 @@ public class ListAction implements NotificationsWsAction { public ListAction(NotificationCenter notificationCenter, DbClient dbClient, UserSession userSession, Dispatchers dispatchers) { this.dbClient = dbClient; this.userSession = userSession; - this.channels = notificationCenter.getChannels().stream().map(NotificationChannel::getKey).sorted().collect(MoreCollectors.toList()); + this.channels = notificationCenter.getChannels().stream().map(NotificationChannel::getKey).sorted().collect(Collectors.toList()); this.dispatchers = dispatchers; } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/NotificationUpdater.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/NotificationUpdater.java index 5b08dd4e292..30dd01a2bbd 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/NotificationUpdater.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/notification/ws/NotificationUpdater.java @@ -21,8 +21,8 @@ package org.sonar.server.notification.ws; import java.util.List; import java.util.function.Predicate; +import java.util.stream.Collectors; import javax.annotation.Nullable; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.entity.EntityDto; @@ -60,7 +60,7 @@ public class NotificationUpdater { .build(), dbSession).stream() .filter(notificationScope(project)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); checkArgument(existingNotification.isEmpty() || !PROP_NOTIFICATION_VALUE.equals(existingNotification.get(0).getValue()), "Notification already added"); @@ -90,7 +90,7 @@ public class NotificationUpdater { .build(), dbSession).stream() .filter(notificationScope(project)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); checkArgument(!existingNotification.isEmpty() && PROP_NOTIFICATION_VALUE.equals(existingNotification.get(0).getValue()), "Notification doesn't exist"); dbClient.propertiesDao().delete(dbSession, new PropertyDto() diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionChange.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionChange.java index 28a6cd38bfa..9ead300f9fa 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionChange.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionChange.java @@ -19,13 +19,13 @@ */ package org.sonar.server.permission; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.db.entity.EntityDto; import org.sonar.db.permission.GlobalPermission; import static java.util.Objects.requireNonNull; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.exceptions.BadRequestException.checkRequest; public abstract class PermissionChange { @@ -47,7 +47,7 @@ public abstract class PermissionChange { if (entity == null) { checkRequest(permissionService.getGlobalPermissions().stream().anyMatch(p -> p.getKey().equals(permission)), "Invalid global permission '%s'. Valid values are %s", permission, - permissionService.getGlobalPermissions().stream().map(GlobalPermission::getKey).collect(toList())); + permissionService.getGlobalPermissions().stream().map(GlobalPermission::getKey).collect(Collectors.toList())); } else { checkRequest(permissionService.getAllProjectPermissions().contains(permission), "Invalid project permission '%s'. Valid values are %s", permission, permissionService.getAllProjectPermissions()); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java index 4ab1c4a4b4b..9fac252f555 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchAction.java @@ -22,6 +22,7 @@ package org.sonar.server.projectanalysis.ws; import java.util.EnumSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.sonar.api.resources.Qualifiers; import org.sonar.api.resources.Scopes; import org.sonar.api.server.ws.Change; @@ -45,7 +46,6 @@ import static com.google.common.base.Preconditions.checkArgument; import static java.util.Optional.ofNullable; import static org.sonar.api.utils.DateUtils.parseEndingDateOrDateTime; import static org.sonar.api.utils.DateUtils.parseStartingDateOrDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.component.SnapshotDto.STATUS_LIVE_MEASURE_COMPUTED; import static org.sonar.db.component.SnapshotDto.STATUS_PROCESSED; import static org.sonar.db.component.SnapshotDto.STATUS_UNPROCESSED; @@ -185,7 +185,7 @@ public class SearchAction implements ProjectAnalysesWsAction { } private void addEvents(SearchData.Builder data) { - List<String> analyses = data.getAnalyses().stream().map(SnapshotDto::getUuid).collect(toList()); + List<String> analyses = data.getAnalyses().stream().map(SnapshotDto::getUuid).collect(Collectors.toList()); data.setEvents(dbClient.eventDao().selectByAnalysisUuids(data.getDbSession(), analyses)); data.setComponentChanges(dbClient.eventComponentChangeDao().selectByAnalysisUuids(data.getDbSession(), analyses)); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchData.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchData.java index 47c3005cfdd..42019a0969c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchData.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projectanalysis/ws/SearchData.java @@ -106,7 +106,7 @@ class SearchData { .limit(request.getPageSize()); } - this.analyses = stream.collect(MoreCollectors.toList()); + this.analyses = stream.collect(Collectors.toList()); this.countAnalyses = analyses.size(); return this; } @@ -165,7 +165,7 @@ class SearchData { .filter(byCategory) .skip(Paging.offset(request.getPage(), request.getPageSize())) .limit(request.getPageSize()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } SearchData build() { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projecttag/TagsWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projecttag/TagsWsSupport.java index da16ab046d3..42ac4a30dd4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projecttag/TagsWsSupport.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/projecttag/TagsWsSupport.java @@ -22,10 +22,10 @@ package org.sonar.server.projecttag; import java.util.List; import java.util.Locale; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.apache.commons.lang.StringUtils; import org.sonar.api.utils.System2; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.project.ProjectDto; @@ -85,7 +85,7 @@ public class TagsWsSupport { .map(t -> t.toLowerCase(Locale.ENGLISH)) .map(TagsWsSupport::checkTag) .distinct() - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private static String checkTag(String tag) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ListAction.java index e683ed7bba0..1bd1ef96e5d 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ListAction.java @@ -21,6 +21,7 @@ package org.sonar.server.qualitygate.ws; import com.google.common.io.Resources; import java.util.Collection; +import java.util.stream.Collectors; import javax.annotation.Nullable; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; @@ -34,7 +35,6 @@ import org.sonar.server.qualitygate.QualityGateFinder; import org.sonarqube.ws.Qualitygates.ListWsResponse; import org.sonarqube.ws.Qualitygates.ListWsResponse.QualityGate; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class ListAction implements QualityGatesWsAction { @@ -91,7 +91,7 @@ public class ListAction implements QualityGatesWsAction { .setCaycStatus(qualityGateCaycChecker.checkCaycCompliant(dbSession, qualityGate.getUuid()).toString()) .setActions(wsSupport.getActions(dbSession, qualityGate, defaultQualityGate)) .build()) - .collect(toList())); + .collect(Collectors.toList())); return builder.build(); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java index a888645d3b9..defd7bb07a6 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchAction.java @@ -22,13 +22,13 @@ package org.sonar.server.qualitygate.ws; import com.google.common.io.Resources; import java.util.Collection; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.Paging; import org.sonar.api.web.UserRole; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.qualitygate.ProjectQgateAssociationDto; @@ -147,8 +147,8 @@ public class SearchAction implements QualityGatesWsAction { } private List<ProjectQgateAssociationDto> keepAuthorizedProjects(DbSession dbSession, List<ProjectQgateAssociationDto> projects) { - List<String> projectUuids = projects.stream().map(ProjectQgateAssociationDto::getUuid).collect(MoreCollectors.toList()); + List<String> projectUuids = projects.stream().map(ProjectQgateAssociationDto::getUuid).collect(Collectors.toList()); Collection<String> authorizedProjectUuids = dbClient.authorizationDao().keepAuthorizedEntityUuids(dbSession, projectUuids, userSession.getUuid(), UserRole.USER); - return projects.stream().filter(project -> authorizedProjectUuids.contains(project.getUuid())).collect(MoreCollectors.toList()); + return projects.stream().filter(project -> authorizedProjectUuids.contains(project.getUuid())).collect(Collectors.toList()); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchGroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchGroupsAction.java index e8478ede9e9..68c1b81af5c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchGroupsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchGroupsAction.java @@ -21,6 +21,7 @@ package org.sonar.server.qualitygate.ws; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -42,7 +43,6 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.server.ws.WebService.SelectionMode.ALL; import static org.sonar.api.server.ws.WebService.SelectionMode.DESELECTED; import static org.sonar.api.server.ws.WebService.SelectionMode.fromParam; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.Pagination.forPage; import static org.sonar.db.qualitygate.SearchQualityGatePermissionQuery.builder; import static org.sonar.db.user.SearchPermissionQuery.ANY; @@ -103,14 +103,14 @@ public class SearchGroupsAction implements QualityGatesWsAction { List<SearchGroupMembershipDto> groupMemberships = dbClient.qualityGateGroupPermissionsDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize())); Map<String, GroupDto> groupsByUuid = dbClient.groupDao().selectByUuids(dbSession, - groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(MoreCollectors.toList())) + groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(Collectors.toList())) .stream() .collect(MoreCollectors.uniqueIndex(GroupDto::getUuid)); writeProtobuf( Qualitygates.SearchGroupsResponse.newBuilder() .addAllGroups(groupMemberships.stream() .map(groupsMembership -> toGroup(groupsByUuid.get(groupsMembership.getGroupUuid()), groupsMembership.isSelected())) - .collect(toList())) + .collect(Collectors.toList())) .setPaging(buildPaging(wsRequest, total)).build(), request, response); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchUsersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchUsersAction.java index baaf7177278..62893d0606c 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchUsersAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/SearchUsersAction.java @@ -21,6 +21,7 @@ package org.sonar.server.qualitygate.ws; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; @@ -44,7 +45,6 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.server.ws.WebService.SelectionMode.ALL; import static org.sonar.api.server.ws.WebService.SelectionMode.DESELECTED; import static org.sonar.api.server.ws.WebService.SelectionMode.fromParam; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.Pagination.forPage; import static org.sonar.db.qualitygate.SearchQualityGatePermissionQuery.builder; @@ -107,13 +107,13 @@ public class SearchUsersAction implements QualityGatesWsAction { int total = dbClient.qualityGateUserPermissionDao().countByQuery(dbSession, query); List<SearchUserMembershipDto> usersMembership = dbClient.qualityGateUserPermissionDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize())); - Map<String, UserDto> usersById = dbClient.userDao().selectByUuids(dbSession, usersMembership.stream().map(SearchUserMembershipDto::getUserUuid).collect(toList())) + Map<String, UserDto> usersById = dbClient.userDao().selectByUuids(dbSession, usersMembership.stream().map(SearchUserMembershipDto::getUserUuid).collect(Collectors.toList())) .stream().collect(uniqueIndex(UserDto::getUuid)); writeProtobuf( SearchUsersResponse.newBuilder() .addAllUsers(usersMembership.stream() .map(userMembershipDto -> toUser(usersById.get(userMembershipDto.getUserUuid()), userMembershipDto.isSelected())) - .collect(toList())) + .collect(Collectors.toList())) .setPaging(buildPaging(wsRequest, total)).build(), request, response); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java index 3920cb3c2ac..fa71652ad4b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualitygate/ws/ShowAction.java @@ -24,6 +24,7 @@ import java.util.Collection; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -40,7 +41,6 @@ import org.sonarqube.ws.Qualitygates.ShowWsResponse; import static com.google.common.base.Preconditions.checkState; import static java.util.Optional.ofNullable; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.server.qualitygate.ws.QualityGatesWsParameters.PARAM_NAME; @@ -115,7 +115,7 @@ public class ShowAction implements QualityGatesWsAction { .setCaycStatus(caycStatus.toString()) .addAllConditions(conditions.stream() .map(toWsCondition(metricsByUuid)) - .collect(toList())) + .collect(Collectors.toList())) .setActions(wsSupport.getActions(dbSession, qualityGate, defaultQualityGate)) .build(); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java index 8a5f210e307..1412537a368 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/RegisterQualityProfiles.java @@ -108,7 +108,7 @@ public class RegisterQualityProfiles implements Startable { String inheritance = change.getActiveRule().getInheritance(); return inheritance == null || NONE.name().equals(inheritance); }) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); } }); if (!changedProfiles.isEmpty()) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImpl.java index ba3568f04f3..009ee69fd30 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImpl.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileInsertImpl.java @@ -28,6 +28,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.rule.RuleKey; @@ -84,7 +85,7 @@ public class BuiltInQProfileInsertImpl implements BuiltInQProfileInsert { List<ActiveRuleChange> changes = builtInQProfile.getActiveRules().stream() .map(activeRule -> insertActiveRule(batchDbSession, ruleProfile, activeRule, now.getTime())) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); changes.forEach(change -> dbClient.qProfileChangeDao().insert(batchDbSession, change.toDto(null))); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java index 051a18ba7ae..95b58d1fa9e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/builtin/BuiltInQProfileRepositoryImpl.java @@ -142,7 +142,7 @@ public class BuiltInQProfileRepositoryImpl implements BuiltInQProfileRepository .filter(BuiltInQProfileRepositoryImpl::ensureAtMostOneDeclaredDefault) .map(entry -> toQualityProfiles(entry.getValue())) .flatMap(Collection::stream) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); } private Map<RuleKey, RuleDto> loadRuleDefinitionsByRuleKey() { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java index e115138c304..16ccfa2eca3 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/ProjectsAction.java @@ -22,6 +22,7 @@ package org.sonar.server.qualityprofile.ws; import java.util.Collection; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; @@ -101,7 +102,7 @@ public class ProjectsAction implements QProfileWsAction { List<ProjectQprofileAssociationDto> projects = loadAllProjects(profileKey, session, selected, query).stream() .sorted(comparing(ProjectQprofileAssociationDto::getProjectName) .thenComparing(ProjectQprofileAssociationDto::getProjectUuid)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); Collection<String> projectUuids = projects.stream() .map(ProjectQprofileAssociationDto::getProjectUuid) @@ -114,7 +115,7 @@ public class ProjectsAction implements QProfileWsAction { .filter(input -> authorizedProjectUuids.contains(input.getProjectUuid())) .skip(paging.offset()) .limit(paging.pageSize()) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); writeProjects(response, authorizedProjects, paging); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java index f9418ab2f07..26269cabc6e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchAction.java @@ -58,7 +58,6 @@ import static java.util.Optional.ofNullable; import static java.util.function.Function.identity; import static org.sonar.api.rule.RuleStatus.DEPRECATED; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.permission.GlobalPermission.ADMINISTER_QUALITY_PROFILES; import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001; import static org.sonar.server.ws.WsUtils.writeProtobuf; @@ -179,7 +178,7 @@ public class SearchAction implements QProfileWsAction { return Stream.concat( dbClient.qProfileEditUsersDao().selectQProfileUuidsByUser(dbSession, user).stream(), dbClient.qProfileEditGroupsDao().selectQProfileUuidsByGroups(dbSession, userSession.getGroups()).stream()) - .collect(toList()); + .collect(Collectors.toList()); } private List<QProfileDto> searchProfiles(DbSession dbSession, SearchRequest request, List<QProfileDto> defaultProfiles, @Nullable ProjectDto project) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java index 31ca978b3fb..10e5f3f33c8 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java @@ -22,6 +22,7 @@ package org.sonar.server.qualityprofile.ws; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; import org.sonar.api.server.ws.Request; @@ -45,7 +46,6 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.server.ws.WebService.SelectionMode.ALL; import static org.sonar.api.server.ws.WebService.SelectionMode.DESELECTED; import static org.sonar.api.server.ws.WebService.SelectionMode.fromParam; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.db.Pagination.forPage; import static org.sonar.db.qualityprofile.SearchQualityProfilePermissionQuery.ANY; @@ -117,14 +117,14 @@ public class SearchGroupsAction implements QProfileWsAction { List<SearchGroupMembershipDto> groupMemberships = dbClient.qProfileEditGroupsDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize())); Map<String, GroupDto> groupsByUuid = dbClient.groupDao().selectByUuids(dbSession, - groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(MoreCollectors.toList())) + groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(Collectors.toList())) .stream() .collect(MoreCollectors.uniqueIndex(GroupDto::getUuid)); writeProtobuf( Qualityprofiles.SearchGroupsResponse.newBuilder() .addAllGroups(groupMemberships.stream() .map(groupsMembership -> toGroup(groupsByUuid.get(groupsMembership.getGroupUuid()), groupsMembership.isSelected())) - .collect(toList())) + .collect(Collectors.toList())) .setPaging(buildPaging(wsRequest, total)).build(), request, response); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchUsersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchUsersAction.java index fe467a8b73c..31460d37fc2 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchUsersAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchUsersAction.java @@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap; import java.util.Arrays; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import org.sonar.api.resources.Language; import org.sonar.api.resources.Languages; import org.sonar.api.server.ws.Request; @@ -48,7 +49,6 @@ import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.server.ws.WebService.SelectionMode.ALL; import static org.sonar.api.server.ws.WebService.SelectionMode.DESELECTED; import static org.sonar.api.server.ws.WebService.SelectionMode.fromParam; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.core.util.stream.MoreCollectors.uniqueIndex; import static org.sonar.db.Pagination.forPage; @@ -122,13 +122,13 @@ public class SearchUsersAction implements QProfileWsAction { int total = dbClient.qProfileEditUsersDao().countByQuery(dbSession, query); List<SearchUserMembershipDto> usersMembership = dbClient.qProfileEditUsersDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize())); - Map<String, UserDto> usersById = dbClient.userDao().selectByUuids(dbSession, usersMembership.stream().map(SearchUserMembershipDto::getUserUuid).collect(toList())) + Map<String, UserDto> usersById = dbClient.userDao().selectByUuids(dbSession, usersMembership.stream().map(SearchUserMembershipDto::getUserUuid).collect(Collectors.toList())) .stream().collect(uniqueIndex(UserDto::getUuid)); writeProtobuf( SearchUsersResponse.newBuilder() .addAllUsers(usersMembership.stream() .map(userMembershipDto -> toUser(usersById.get(userMembershipDto.getUserUuid()), userMembershipDto.isSelected())) - .collect(toList())) + .collect(Collectors.toList())) .setPaging(buildPaging(wsRequest, total)).build(), request, response); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java index 00c4f510b5f..f8276d1ef54 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/ActiveRuleCompleter.java @@ -192,7 +192,7 @@ public class ActiveRuleCompleter { .map(QProfileDto::getParentKee) .filter(StringUtils::isNotEmpty) .filter(uuid -> !profilesByUuid.containsKey(uuid)) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); if (!parentUuids.isEmpty()) { dbClient.qualityProfileDao().selectByUuids(dbSession, parentUuids) .forEach(p -> profilesByUuid.put(p.getKee(), p)); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java index dddecdb2a5b..1b765e700bd 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/RuleMapper.java @@ -50,7 +50,6 @@ import org.sonarqube.ws.Common.RuleScope; import org.sonarqube.ws.Rules; import static org.sonar.api.utils.DateUtils.formatDateTime; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.db.rule.RuleDto.Format.MARKDOWN; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_CREATED_AT; import static org.sonar.server.rule.ws.RulesWsParameters.FIELD_DEBT_REM_FUNCTION; @@ -319,7 +318,7 @@ public class RuleMapper { private static void setParams(Rules.Rule.Builder ruleResponse, RuleDto ruleDto, SearchResult searchResult, Set<String> fieldsToReturn) { if (shouldReturnField(fieldsToReturn, FIELD_PARAMS)) { List<RuleParamDto> ruleParameters = searchResult.getRuleParamsByRuleUuid().get(ruleDto.getUuid()); - ruleResponse.getParamsBuilder().addAllParams(ruleParameters.stream().map(RuleParamDtoToWsRuleParam.INSTANCE).collect(toList())); + ruleResponse.getParamsBuilder().addAllParams(ruleParameters.stream().map(RuleParamDtoToWsRuleParam.INSTANCE).collect(Collectors.toList())); } } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java index cbf97562dd6..9252c502c8b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/rule/ws/SearchAction.java @@ -43,7 +43,6 @@ import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.rule.DeprecatedRuleKeyDto; @@ -292,7 +291,7 @@ public class SearchAction implements RulesWsAction { List<String> templateRuleUuids = rules.stream() .map(RuleDto::getTemplateUuid) .filter(Objects::nonNull) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); List<RuleDto> templateRules = dbClient.ruleDao().selectByUuids(dbSession, templateRuleUuids); List<RuleParamDto> ruleParamDtos = dbClient.ruleDao().selectRuleParamsByRuleUuids(dbSession, ruleUuids); return new SearchResult() diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/SourceService.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/SourceService.java index 5d93809d5ab..6beaebf8e36 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/SourceService.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/source/SourceService.java @@ -22,7 +22,7 @@ package org.sonar.server.source; import java.util.Optional; import java.util.Set; import java.util.function.Function; -import org.sonar.core.util.stream.MoreCollectors; +import java.util.stream.Collectors; import org.sonar.db.DbClient; import org.sonar.db.DbSession; import org.sonar.db.protobuf.DbFileSources; @@ -80,7 +80,7 @@ public class SourceService { .filter(line -> line.hasLine() && line.getLine() >= from) .limit((toInclusive - from) + 1L) .map(function) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); } private <E> Optional<Iterable<E>> getLines(DbSession dbSession, String fileUuid, Set<Integer> lines, Function<DbFileSources.Line, E> function) { @@ -91,7 +91,7 @@ public class SourceService { return Optional.of(dto.getSourceData().getLinesList().stream() .filter(line -> line.hasLine() && lines.contains(line.getLine())) .map(function) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); } private static void verifyLine(int line) { diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageRepository.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageRepository.java index a2402d71b72..dbca4b42f19 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageRepository.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ui/PageRepository.java @@ -23,6 +23,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableList; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import javax.annotation.Nullable; import org.sonar.api.Startable; import org.sonar.api.server.ServerSide; @@ -42,7 +43,7 @@ import static java.util.Comparator.comparing; import static java.util.Objects.requireNonNull; import static org.sonar.api.web.page.Page.Scope.COMPONENT; import static org.sonar.api.web.page.Page.Scope.GLOBAL; -import static org.sonar.core.util.stream.MoreCollectors.toList; + import org.springframework.beans.factory.annotation.Autowired; @ServerSide @@ -135,7 +136,7 @@ public class PageRepository implements Startable { .filter(p -> p.getScope().equals(scope)) .filter(p -> p.isAdmin() == isAdmin) .filter(p -> !COMPONENT.equals(p.getScope()) || p.getComponentQualifiers().contains(qualifier)) - .collect(toList()); + .collect(Collectors.toList()); } @VisibleForTesting diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/IdentityProvidersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/IdentityProvidersAction.java index c90f867cdf2..a61e3b4614b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/IdentityProvidersAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/IdentityProvidersAction.java @@ -20,12 +20,12 @@ package org.sonar.server.user.ws; import java.util.function.Function; +import java.util.stream.Collectors; import org.sonar.api.server.authentication.Display; import org.sonar.api.server.authentication.IdentityProvider; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; -import org.sonar.core.util.stream.MoreCollectors; import org.sonar.server.authentication.IdentityProviderRepository; import org.sonarqube.ws.Users; import org.sonarqube.ws.Users.IdentityProvidersWsResponse; @@ -60,7 +60,7 @@ public class IdentityProvidersAction implements UsersWsAction { response.addAllIdentityProviders(identityProviderRepository.getAllEnabledAndSorted() .stream() .map(toWsIdentityProvider()) - .collect(MoreCollectors.toList())); + .collect(Collectors.toList())); return response.build(); } diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SearchAction.java index e0d3e4d8b7a..672d33488dd 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SearchAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/SearchAction.java @@ -60,7 +60,6 @@ import static org.sonar.api.server.ws.WebService.Param.PAGE; import static org.sonar.api.server.ws.WebService.Param.PAGE_SIZE; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.api.utils.Paging.forPageIndex; -import static org.sonar.core.util.stream.MoreCollectors.toList; import static org.sonar.server.ws.WsUtils.writeProtobuf; import static org.sonarqube.ws.Users.SearchWsResponse.Groups; import static org.sonarqube.ws.Users.SearchWsResponse.ScmAccounts; @@ -193,7 +192,7 @@ public class SearchAction implements UsersWsAction { List<UserDto> users = findUsersAndSortByLogin(request, dbSession, userQuery); int totalUsers = dbClient.userDao().countUsers(dbSession, userQuery); - List<String> logins = users.stream().map(UserDto::getLogin).collect(toList()); + List<String> logins = users.stream().map(UserDto::getLogin).collect(Collectors.toList()); Multimap<String, String> groupsByLogin = dbClient.groupMembershipDao().selectGroupsByLogins(dbSession, logins); Map<String, Integer> tokenCountsByLogin = dbClient.userTokenDao().countTokensByUsers(dbSession, users); Map<String, Boolean> userUuidToIsManaged = managedInstanceService.getUserUuidToManaged(dbSession, getUserUuids(users)); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ws/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ws/ws/ListAction.java index bd97a993d59..46214283ed6 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ws/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/ws/ws/ListAction.java @@ -22,13 +22,13 @@ package org.sonar.server.ws.ws; import com.google.common.collect.Ordering; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; import org.sonar.api.server.ws.Change; import org.sonar.api.server.ws.Request; import org.sonar.api.server.ws.Response; import org.sonar.api.server.ws.WebService; import org.sonar.api.utils.Version; import org.sonar.api.utils.text.JsonWriter; -import org.sonar.core.util.stream.MoreCollectors; import static com.google.common.base.Preconditions.checkState; import static java.util.Optional.ofNullable; @@ -110,7 +110,7 @@ public class ListAction implements WebServicesWsAction { } private static void writeParameters(JsonWriter writer, WebService.Action action, boolean includeInternals) { - List<WebService.Param> params = action.params().stream().filter(p -> includeInternals || !p.isInternal()).collect(MoreCollectors.toList()); + List<WebService.Param> params = action.params().stream().filter(p -> includeInternals || !p.isInternal()).collect(Collectors.toList()); if (!params.isEmpty()) { // sort parameters by key Ordering<WebService.Param> ordering = Ordering.natural().onResultOf(WebService.Param::key); diff --git a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/RedirectFilter.java b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/RedirectFilter.java index 7d8b6ccea25..87a1fcaffc6 100644 --- a/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/RedirectFilter.java +++ b/server/sonar-webserver/src/main/java/org/sonar/server/platform/web/RedirectFilter.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.util.List; import java.util.function.Function; import java.util.function.Predicate; +import java.util.stream.Collectors; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; @@ -31,7 +32,6 @@ import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.sonar.core.util.stream.MoreCollectors; import static java.lang.String.format; @@ -50,7 +50,7 @@ public class RedirectFilter implements Filter { Predicate<Redirect> match = redirect -> redirect.test(path); List<Redirect> redirects = REDIRECTS.stream() .filter(match) - .collect(MoreCollectors.toList()); + .collect(Collectors.toList()); switch (redirects.size()) { case 0: |