Closes #2521 - Fix code smells Stream.collect(Collectors.toList()) to Stream.toList()

This commit is contained in:
Maria Margaritis 2024-03-06 00:53:06 +01:00
parent 5fe9b344d3
commit 3a75ddccd5
1 changed files with 6 additions and 12 deletions

View File

@ -752,8 +752,7 @@ public class TaskServiceImpl implements TaskService {
List<String> changedTasks = new ArrayList<>();
if (!tasksWithPermissions.isEmpty()) {
changedTasks =
tasksWithPermissions.stream().map(TaskSummary::getId).collect(Collectors.toList());
changedTasks = tasksWithPermissions.stream().map(TaskSummary::getId).toList();
taskMapper.updateTasks(changedTasks, updated, fieldSelector);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks);
@ -794,8 +793,7 @@ public class TaskServiceImpl implements TaskService {
List<String> changedTasks = new ArrayList<>();
if (!tasksWithPermissions.isEmpty()) {
changedTasks =
tasksWithPermissions.stream().map(TaskSummary::getId).collect(Collectors.toList());
changedTasks = tasksWithPermissions.stream().map(TaskSummary::getId).toList();
taskMapper.updateTasks(changedTasks, updatedTask, fieldSelector);
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("updateTasks() updated the following tasks: {} ", changedTasks);
@ -1051,15 +1049,13 @@ public class TaskServiceImpl implements TaskService {
// tasks indirectly affected via attachments
List<Pair<String, Instant>> affectedPairs =
tasksAffectedDirectly.stream()
.map(t -> Pair.of(t.getId(), t.getPlanned()))
.collect(Collectors.toList());
tasksAffectedDirectly.stream().map(t -> Pair.of(t.getId(), t.getPlanned())).toList();
// tasks indirectly affected via attachments
List<Pair<String, Instant>> taskIdsAndPlannedFromAttachments =
attachmentMapper.findTaskIdsAndPlannedAffectedByClassificationChange(classificationId);
List<String> taskIdsFromAttachments =
taskIdsAndPlannedFromAttachments.stream().map(Pair::getLeft).collect(Collectors.toList());
taskIdsAndPlannedFromAttachments.stream().map(Pair::getLeft).toList();
List<Pair<String, Instant>> filteredTaskIdsAndPlannedFromAttachments =
taskIdsFromAttachments.isEmpty()
? new ArrayList<>()
@ -1071,7 +1067,7 @@ public class TaskServiceImpl implements TaskService {
.sorted(Comparator.comparing(Pair::getRight))
.distinct()
.map(Pair::getLeft)
.collect(Collectors.toList());
.toList();
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(
@ -1143,9 +1139,7 @@ public class TaskServiceImpl implements TaskService {
.map(Pair::getLeft)
.collect(Collectors.toSet());
List<MinimalTaskSummary> tasksAuthorizedFor =
existingTasks.stream()
.filter(not(t -> taskIdsToRemove.contains(t.getTaskId())))
.collect(Collectors.toList());
existingTasks.stream().filter(not(t -> taskIdsToRemove.contains(t.getTaskId()))).toList();
return Pair.of(tasksAuthorizedFor, bulkLog);
}
}