Skip to content

Commit

Permalink
feat: improve streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Angular2Guy committed Nov 28, 2024
1 parent d44ba72 commit e4b1726
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public List<Actor> findByFilterCriteria(ActorFilterCriteriaDto filterCriteriaDto
cActor.<Date>get("birthday"), CommonUtils.convert(filterCriteriaDto.getBirthdayTo()))));
Optional.ofNullable(filterCriteriaDto.getDead()).ifPresent(
x -> predicates.add(this.entityManager.getCriteriaBuilder().isNotNull(cActor.<Date>get("deathday"))));
Optional.ofNullable(filterCriteriaDto.getGender()).stream().filter(myGender -> !Gender.Unknown.equals(myGender))
Optional.ofNullable(filterCriteriaDto.getGender()).stream().filter(java.util.function.Predicate.not(Gender.Unknown::equals))
.findFirst().ifPresent(x -> predicates.add(this.entityManager.getCriteriaBuilder()
.equal(cActor.get("gender"), filterCriteriaDto.getGender().getCode())));
Optional.ofNullable(filterCriteriaDto.getName()).stream().filter(myName -> myName.trim().length() > 2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import org.springframework.scheduling.annotation.Async;
Expand All @@ -40,7 +41,7 @@ public DataMigrationService(UserRepository userRepository, UserDetailService use
@Async
public CompletableFuture<Long> encryptUserKeys() {
List<User> migratedUsers = this.userRepository.findOpenMigrations(1L).stream().map(myUser -> {
myUser.setUuid(Optional.ofNullable(myUser.getUuid()).filter(myStr -> !myStr.isBlank()).orElse(UUID.randomUUID().toString()));
myUser.setUuid(Optional.ofNullable(myUser.getUuid()).filter(Predicate.not(String::isBlank)).orElse(UUID.randomUUID().toString()));
myUser.setMoviedbkey(this.userDetailService.encrypt(myUser.getMoviedbkey(), myUser.getUuid()));
myUser.setMigration(myUser.getMigration() + 1);
return myUser;
Expand Down

0 comments on commit e4b1726

Please sign in to comment.