Skip to content

Commit

Permalink
⚡ Refactor/296-async parallelStream+Async
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanvp committed Feb 4, 2024
1 parent 292f0f2 commit e653f9a
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/zipdabang/server/converter/RecipeConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ public static TestRecipe toTestRecipe(RecipeRequestDto.CreateRecipeDto request,


public static CompletableFuture<List<TestRecipeCategoryMapping>> toTestRecipeCategory(List<Long> categoryIds, TestRecipe recipe) {
return CompletableFuture.completedFuture(categoryIds.stream()
return CompletableFuture.completedFuture(categoryIds.stream().parallel()
.map(recipeCategoryId -> toTestRecipeCategoryMappingDto(recipeCategoryId, recipe))
.collect(Collectors.toList()));
}
Expand All @@ -762,7 +762,7 @@ private static TestRecipeCategoryMapping toTestRecipeCategoryMappingDto(Long cat
}

public static CompletableFuture<List<TestStep>> toTestStep(RecipeRequestDto.CreateRecipeDto request, TestRecipe recipe, List<MultipartFile> stepImages) {
return CompletableFuture.completedFuture(request.getSteps().stream()
return CompletableFuture.completedFuture(request.getSteps().stream().parallel()
.map(step-> {
if (step.getDescription() == null)
throw new RecipeException(CommonStatus.NULL_RECIPE_ERROR);
Expand Down Expand Up @@ -805,7 +805,7 @@ private static TestStep toTestStepDto(RecipeRequestDto.StepDto step, TestRecipe
}

public static CompletableFuture<List<TestIngredient>> toTestIngredient(RecipeRequestDto.CreateRecipeDto request, TestRecipe recipe) {
return CompletableFuture.completedFuture(request.getIngredients().stream()
return CompletableFuture.completedFuture(request.getIngredients().stream().parallel()
.map(ingredient -> toTestIngredientDto(ingredient, recipe))
.collect(Collectors.toList()));
}
Expand Down

0 comments on commit e653f9a

Please sign in to comment.