List<CeQueueDto> taskDtos = submissions.stream()
.filter(filterBySubmitOptions(options, submissions, dbSession))
.map(submission -> addToQueueInDb(dbSession, submission))
- .collect(Collectors.toList());
+ .toList();
List<CeTask> tasks = loadTasks(dbSession, taskDtos);
dbSession.commit();
return tasks;
try (var dbSession = dbClient.openSession(false)) {
var expiringTokens = dbClient.userTokenDao().selectTokensExpiredInDays(dbSession, 7);
var expiredTokens = dbClient.userTokenDao().selectTokensExpiredInDays(dbSession, 0);
- var tokensToNotify = Stream.concat(expiringTokens.stream(), expiredTokens.stream()).collect(Collectors.toList());
+ var tokensToNotify = Stream.concat(expiringTokens.stream(), expiredTokens.stream()).toList();
var usersToNotify = tokensToNotify.stream().map(UserTokenDto::getUserUuid).collect(Collectors.toSet());
Map<String, String> userUuidToEmail = dbClient.userDao().selectByUuids(dbSession, usersToNotify).stream()
.collect(Collectors.toMap(UserDto::getUuid, UserDto::getEmail));
import org.sonar.db.component.BranchType;
import org.sonar.db.component.SnapshotDto;
+import static java.util.stream.Collectors.toCollection;
import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_KEY;
import static org.sonar.db.ce.CeTaskCharacteristicDto.BRANCH_TYPE_KEY;
import static org.sonar.db.ce.CeTaskCharacteristicDto.PULL_REQUEST;
return;
}
- List<String> projectUuids = branchInNeedOfIssueSync.stream().map(BranchDto::getProjectUuid).distinct().collect(Collectors.toList());
+ List<String> projectUuids = branchInNeedOfIssueSync.stream().map(BranchDto::getProjectUuid).distinct().collect(toCollection(ArrayList<String>::new));
LOG.info("{} projects found in need of issue sync.", projectUuids.size());
sortProjectUuids(dbSession, projectUuids);
import static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
import static java.util.Collections.singletonList;
-import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toCollection;
import static org.elasticsearch.index.query.QueryBuilders.boolQuery;
import static org.elasticsearch.index.query.QueryBuilders.existsQuery;
import static org.elasticsearch.index.query.QueryBuilders.matchAllQuery;
List<SecurityStandardCategoryStatistics> children = new ArrayList<>();
if (includeDistribution) {
Stream<? extends Terms.Bucket> stream = ((ParsedStringTerms) categoryBucket.getAggregations().get(AGG_DISTRIBUTION)).getBuckets().stream();
- children = stream.map(cweBucket -> processSecurityReportCategorySearchResults(cweBucket, cweBucket.getKeyAsString(), null, null)).collect(toList());
+ children = stream.map(cweBucket -> processSecurityReportCategorySearchResults(cweBucket, cweBucket.getKeyAsString(), null, null))
+ .collect(toCollection(ArrayList<SecurityStandardCategoryStatistics>::new));
}
return processSecurityReportCategorySearchResults(categoryBucket, categoryBucket.getName(), children, version);
package org.sonar.server.setting.ws;
import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableTable;
import java.util.Collections;
+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.api.config.PropertyDefinition;
if (propertySets.isEmpty()) {
return Collections.emptyList();
}
- ImmutableTable.Builder<String, String, String> tableBuilder = new ImmutableTable.Builder<>();
+ Map<String, Map<String, String>> table = new HashMap<>();
propertySets.forEach(property -> {
String keyWithoutSettingKey = property.getKey().replace(propertyKey + ".", "");
List<String> setIdWithFieldKey = DOT_SPLITTER.splitToList(keyWithoutSettingKey);
String setId = setIdWithFieldKey.get(0);
String fieldKey = keyWithoutSettingKey.replaceFirst(setId + ".", "");
- tableBuilder.put(setId, fieldKey, property.getValue());
+ table.computeIfAbsent(setId, k -> new HashMap<>()).put(fieldKey, property.getValue());
});
- ImmutableTable<String, String, String> table = tableBuilder.build();
- return table.rowKeySet().stream()
- .map(table::row)
- .collect(Collectors.toList());
+ return table.keySet().stream()
+ .map(table::get)
+ .toList();
}
}