Skip to content

Commit

Permalink
[Gepardec/mega#727] change .collect to .toList
Browse files Browse the repository at this point in the history
  • Loading branch information
gattrCh committed May 28, 2024
1 parent 611c840 commit 308ae10
Show file tree
Hide file tree
Showing 41 changed files with 72 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private List<ValidationViolation> createResponseEntityForConstraintViolationExce
}
return violations.stream()
.map(this::createValidationViolationForConstraintViolation)
.collect(Collectors.toList());
.toList();
}

private ValidationViolation createValidationViolationForConstraintViolation(final ConstraintViolation<?> violation) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public List<JourneyWarning> calculate(List<ProjectEntry> projectTimeEntries) {
.filter(entry -> Task.isJourney(entry.getTask()))
.map(JourneyTimeEntry.class::cast)
.sorted(Comparator.comparing(ProjectEntry::getFromTime).thenComparing(ProjectEntry::getToTime))
.collect(Collectors.toList());
.toList();

final List<JourneyWarning> warnings = new ArrayList<>();
final JourneyDirectionValidator journeyDirectionValidator = new JourneyDirectionValidator();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class InvalidWorkingLocationInJourneyCalculator implements WarningCalcula
public List<JourneyWarning> calculate(List<ProjectEntry> projectTimeEntries) {
final List<ProjectEntry> groupedProjectTimeEntries = projectTimeEntries.stream()
.sorted(Comparator.comparing(ProjectEntry::getFromTime).thenComparing(ProjectEntry::getToTime))
.collect(Collectors.toList());
.toList();

final List<JourneyWarning> warnings = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public List<TimeWarning> calculate(List<ProjectEntry> projectEntries) {
final List<ProjectTimeEntry> projectTimeEntries = projectEntries.stream()
.filter(projectEntry -> projectEntry.getClass() == ProjectTimeEntry.class)
.map(ProjectTimeEntry.class::cast)
.collect(Collectors.toList());
.toList();


LocalTime projectEntryFromTime, projectEntryToTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private List<ProjectEntry> filterForTaskAndSortByFromDate(final List<ProjectEntr
return projectTimeEntries.stream()
.filter(filterTask.or(filterActiveTravelTime))
.sorted(Comparator.comparing(ProjectEntry::getFromTime).thenComparing(ProjectEntry::getToTime))
.collect(Collectors.toList());
.toList();
}

private ProjectEntry getNextEntryOrNull(final int idx, final List<ProjectEntry> projectTimeEntries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public List<TimeWarning> calculate(@NotNull Employee employee, @NotNull List<Pro
List<LocalDate> nonPaidVacationDays = filterAbsenceTypesAndCompileLocalDateList(AbsenteeType.NON_PAID_VACATION_DAYS.getType(), absenceEntries);
List<LocalDate> bookedDays = projectEntries.stream()
.map(ProjectEntry::getDate)
.collect(Collectors.toList());
.toList();

return businessDays.stream()
.filter(date -> !compensatoryDays.contains(date))
Expand All @@ -75,7 +75,7 @@ public List<TimeWarning> calculate(@NotNull Employee employee, @NotNull List<Pro
.filter(date -> !futureDays.contains(date))
.map(this::createTimeWarning)
.distinct()
.collect(Collectors.toList());
.toList();
}

private List<LocalDate> getBusinessDaysOfMonth(int year, int month) {
Expand Down Expand Up @@ -108,7 +108,7 @@ private List<LocalDate> getRegularWorkingHours0Dates(Employee employee, int year
private List<LocalDate> getFutureDays() {
LocalDate today = LocalDate.now();
return today.datesUntil(today.with(TemporalAdjusters.firstDayOfNextMonth()))
.collect(Collectors.toList());
.toList();
}

private TimeWarning createTimeWarning(final LocalDate date) {
Expand All @@ -123,7 +123,7 @@ private List<LocalDate> filterAbsenceTypesAndCompileLocalDateList(String type, L
return absenceEntries.stream()
.filter(fzt -> fzt.reason().equals(type))
.flatMap(this::extractFehlzeitenDateRange)
.collect(Collectors.toList());
.toList();
}

private Stream<LocalDate> extractFehlzeitenDateRange(AbsenceTime fzt) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private List<LocalDate> getWeekEndDays(LocalDate startDate, LocalDate endDate) {
endDate = endDate.plusDays(1);
return startDate.datesUntil(endDate)
.filter(isWeekend)
.collect(Collectors.toList());
.toList();
}

private boolean isWeekEndDay(LocalDate date, List<LocalDate> listOfWeekendDays) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public interface EntityMapper<D, E> {
default List<E> mapListToEntity(List<D> objects) {
return objects.stream()
.map(this::mapToEntity)
.collect(Collectors.toList());
.toList();
}

default List<D> mapListToDomain(List<E> objects) {
return objects.stream()
.map(this::mapToDomain)
.collect(Collectors.toList());
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class OfficeCalendarUtil {
public static List<LocalDate> getWorkingDaysBetween(LocalDate startDate, LocalDate endDateInclusive) {
return startDate.datesUntil(endDateInclusive.plusDays(1))
.filter(isWeekend.or(isHoliday).negate())
.collect(Collectors.toList());
.toList();
}

public static boolean isHoliday(LocalDate date) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ private ProjectManagementEntryDto loadProjectManagementEntryDto(ProjectEmployees

Duration billable = calculateProjectDuration(entries.stream()
.map(ManagementEntryDto::getBillableTime)
.collect(Collectors.toList()));
.toList());

Duration nonBillable = calculateProjectDuration(entries.stream()
.map(ManagementEntryDto::getNonBillableTime)
.collect(Collectors.toList()));
.toList());

// it is guaranteed that the same Project instance is obtained for every ProjectEntry
Integer zepId = Optional.ofNullable(projectEntries.get(0))
Expand Down Expand Up @@ -221,7 +221,7 @@ public Response getProjectsWithoutLeads() {
.comment("Dieses Projekt hat keinen Projektleiter zugewiesen. Bitte in ZEP hinzufügen!")
.zepId(project.getZepId())
.build())
.collect(Collectors.toList());
.toList();

return Response.ok(customerProjectsWithoutLeadsDto).build();
}
Expand Down Expand Up @@ -380,7 +380,7 @@ private com.gepardec.mega.domain.model.State extractStateForProject(List<StepEnt
}
})
.map(StepEntry::getState)
.collect(Collectors.toList());
.toList();

if (projectStateLogicSingle) {
return collectedStates.stream()
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/gepardec/mega/rest/mapper/DtoMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ public interface DtoMapper<D, T> {
default List<T> mapListToDto(List<D> objects) {
return objects.stream()
.map(this::mapToDto)
.collect(Collectors.toList());
.toList();
}

default List<D> mapListToDomain(List<T> objects) {
return objects.stream()
.map(this::mapToDomain)
.collect(Collectors.toList());
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public double getOvertimeForEmployee(Employee employee,
// In case there are absences that do not affect the current month, filter them out
fehlzeitTypeList = fehlzeitTypeList.stream()
.filter(ftl -> ftl.fromDate().getMonthValue() == date.getMonthValue())
.collect(Collectors.toList());
.toList();

//FIXME
var workingDaysCountMap = getWorkingDaysBetween(date, DateUtils.getLastDayOfCurrentMonth(date.toString()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public List<Comment> findCommentsForEmployee(final String employeeEmail,
)
.stream()
.map(commentMapper::mapToDomain)
.collect(Collectors.toList());
.toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ public List<Employee> getAllActiveEmployees() {
return zepService.getEmployees().stream()
.filter(Employee::isActive)
.filter(employee -> Objects.nonNull(employee.getEmail()))
.collect(Collectors.toList());
.toList();
}

@Override
public List<Employee> getAllEmployeesConsideringExitDate(YearMonth selectedYearMonth) {
return zepService.getEmployees().stream()
.filter(checkEmployeeExitDate(selectedYearMonth))
.filter(employee -> Objects.nonNull(employee.getEmail()))
.collect(Collectors.toList());
.toList();
}

@Override
Expand Down Expand Up @@ -123,7 +123,7 @@ private Function<Employee, CompletableFuture<Object>> asyncUpdateEmployeeRelease
}

private List<String> getUserIds(final List<Employee> employees) {
return employees.stream().map(Employee::getUserId).collect(Collectors.toList());
return employees.stream().map(Employee::getUserId).toList();
}

private Predicate<? super Employee> checkEmployeeExitDate(YearMonth selectedYearMonth) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private MonthlyReport buildMonthlyReport(
.orElse(Collections.emptyList())
.stream()
.map(PmProgressDto::ofStepEntry)
.collect(Collectors.toList());
.toList();

List<MappedTimeWarningDTO> mappedTimeWarnings = timeWarningMapper.map(timeWarnings);
var prematureEmployeeCheck = prematureEmployeeCheckService.findByEmailAndMonth(employee.getEmail(), date);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public boolean syncPrematureEmployeeChecksWithStepEntries(YearMonth yearMonth) {
List<PrematureEmployeeCheck> prematureEmployeeCheckEntities = prematureEmployeeCheckService.findAllForMonth(selectedMonth)
.stream()
.filter(pec -> pec.getState().equals(PrematureEmployeeCheckState.DONE) || pec.getState().equals(PrematureEmployeeCheckState.IN_PROGRESS))
.collect(Collectors.toList());
.toList();

logger.info(
String.format("Syncing %s PrematureEmployeeChecks with StepEntries for Month: %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class ProjectCommentServiceImpl implements ProjectCommentService {
@Override
public List<ProjectCommentDto> findForProjectNameInRange(String projectName, LocalDate from, LocalDate to) {
List<ProjectComment> entities = projectCommentRepository.findByProjectNameAndDateBetween(projectName, from, to);
return entities.stream().map(e -> projectCommentMapper.mapToDto(e)).collect(Collectors.toList());
return entities.stream().map(e -> projectCommentMapper.mapToDto(e)).toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public List<Project> getProjectsForMonthYear(final LocalDate monthYear, final Li
return zepService.getProjectsForMonthYear(monthYear)
.stream()
.filter(project -> filterProject(project, Optional.ofNullable(projectFilters).orElse(List.of())))
.collect(Collectors.toList());
.toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ private List<com.gepardec.mega.db.entity.project.Project> createProjects(List<Us
.map(project -> createProjectEntityFromProject(activeUsers, project, date))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
.toList();
}

private Optional<com.gepardec.mega.db.entity.project.Project> createProjectEntityFromProject(List<User> activeUsers, Project project, LocalDate date) {
Expand All @@ -99,7 +99,7 @@ private Optional<com.gepardec.mega.db.entity.project.Project> createProjectEntit
.map(userid -> findUserByUserId(activeUsers, userid))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
.toList();

if (leads.isEmpty()) {
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public List<ProjectEmployees> getProjectEmployeesForPM(final LocalDate from, fin
.entrySet()
.stream()
.map(e -> ProjectEmployees.builder().projectId(e.getKey()).employees(e.getValue()).build())
.collect(Collectors.toList());
.toList();
}

@Override
Expand All @@ -213,7 +213,7 @@ public List<ProjectEmployees> getAllProjectEmployeesForPM(LocalDate from, LocalD
.entrySet()
.stream()
.map(e -> ProjectEmployees.builder().projectId(e.getKey()).employees(e.getValue()).build())
.collect(Collectors.toList());
.toList();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private boolean generateStepEntries(LocalDate date) {
.map(email -> findUserByEmail(activeUsers, email))
.filter(Optional::isPresent)
.map(Optional::get)
.collect(Collectors.toList());
.toList();

logger.info("Loaded projects: {}", projectsForMonthYear.size());
logger.debug("projects are {}", projectsForMonthYear);
Expand Down Expand Up @@ -121,7 +121,7 @@ private boolean generateStepEntries(LocalDate date) {
toBeCreatedFilteredStepEntries = toBeCreatedStepEntries.stream()
.filter(stepEntry -> allEntityStepEntries.stream()
.noneMatch(stepEntry1 -> modelEqualsEntityStepEntry(stepEntry, stepEntry1)))
.collect(Collectors.toList());
.toList();
}


Expand Down Expand Up @@ -149,15 +149,15 @@ private List<StepEntry> createStepEntriesProjectLeadForUsers(final LocalDate dat
return users.stream()
.map(owner -> createStepEntriesForOwnerProjects(date, step, projects, users, owner))
.flatMap(Collection::stream)
.collect(Collectors.toList());
.toList();
}

private List<StepEntry> createStepEntriesForOwnerProjects(final LocalDate date, final Step step, final List<Project> projects, final List<User> users, final User ownerUser) {
return projects.stream()
.filter(project -> project.getEmployees().contains(ownerUser.getUserId()))
.map(project -> createStepEntriesForOwnerProject(date, step, project, users, ownerUser))
.flatMap(Collection::stream)
.collect(Collectors.toList());
.toList();
}

private List<StepEntry> createStepEntriesForOwnerProject(final LocalDate date, final Step step, final Project project, final List<User> users, final User ownerUser) {
Expand All @@ -174,14 +174,14 @@ private List<StepEntry> createStepEntriesForOwnerProject(final LocalDate date, f
.assignee(leadUser)
.step(step)
.build())
.collect(Collectors.toList());
.toList();
}

private List<StepEntry> createStepEntriesOmForUsers(final LocalDate date, final Step step, final List<User> omUsers, final List<User> users) {
return users.stream()
.map(ownerUser -> createStepEntriesForOwnerOmUsers(date, step, omUsers, ownerUser))
.flatMap(Collection::stream)
.collect(Collectors.toList());
.toList();
}

private List<StepEntry> createStepEntriesForOwnerOmUsers(final LocalDate date, final Step step, final List<User> omUsers, final User ownerUser) {
Expand All @@ -194,7 +194,7 @@ private List<StepEntry> createStepEntriesForOwnerOmUsers(final LocalDate date, f
.assignee(omUser)
.step(step)
.build())
.collect(Collectors.toList());
.toList();
}

private List<StepEntry> createStepEntriesForUsers(final LocalDate date, final Step step, final List<User> users) {
Expand All @@ -207,7 +207,7 @@ private List<StepEntry> createStepEntriesForUsers(final LocalDate date, final St
.assignee(ownerUser)
.step(step)
.build())
.collect(Collectors.toList());
.toList();
}

private Optional<User> findUserByUserId(final List<User> users, final String userId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public List<Step> getSteps() {
.ordinal(s.getOrdinal())
.role(s.getRole())
.build())
.collect(Collectors.toList());
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ private List<User> filterNotExistingEmployeesAndMapToUser(final List<Employee> e
return employees.stream()
.filter(zepEmployee -> !zepIdToUser.containsKey(zepEmployee.getUserId()))
.map(employee -> mapper.mapEmployeeToNewUser(employee, projects, defaultLocale))
.collect(Collectors.toList());
.toList();
}

private List<User> filterUserNotMappedToEmployeesAndMarkUserDeactivated(final List<Employee> employees, final List<User> users) {
final Map<String, Employee> zepIdToEmployee = mapZepIdToEmployee(employees);
return users.stream()
.filter(user -> !zepIdToEmployee.containsKey(user.getZepId()))
.map(mapper::mapToDeactivatedUser)
.collect(Collectors.toList());
.toList();
}

private List<User> filterModifiedEmployeesAndUpdateUsers(final List<Employee> employees, final List<User> users, final List<Project> projects) {
Expand All @@ -213,7 +213,7 @@ private List<User> filterModifiedEmployeesAndUpdateUsers(final List<Employee> em
final Locale defaultLocale = applicationConfig.getDefaultLocale();
return existingUserToEmployee.entrySet().stream()
.map(entry -> mapper.mapEmployeeToUser(entry.getKey(), entry.getValue(), projects, defaultLocale))
.collect(Collectors.toList());
.toList();
}

private Map<String, User> mapZepIdToUser(final List<User> users) {
Expand Down
Loading

0 comments on commit 308ae10

Please sign in to comment.