Skip to content

Commit

Permalink
refactor: (#88) PostOptions 생성하는 코드 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
tjdtls690 committed Jul 20, 2023
1 parent 643bccf commit 33b0609
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions backend/src/main/java/com/votogether/domain/post/entity/Post.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,7 @@ private List<PostOption> toPostOptionEntities(
final List<String> postOptionContents,
final List<MultipartFile> images
) {
return IntStream.rangeClosed(FIRST_OPTION_SEQUENCE, postOptionContents.size())
.mapToObj(postOptionSequence ->
PostOption.of(
postOptionContents.get(postOptionSequence - 1),
this,
postOptionSequence,
images.get(postOptionSequence - 1)
)
)
.toList();
return toPostOptions(postOptionContents, images);
}

public boolean hasPostOption(final PostOption postOption) {
Expand Down Expand Up @@ -139,4 +130,17 @@ private void validatePostOption(PostOption postOption) {
}
}

private List<PostOption> toPostOptions(final List<String> postOptionContents, final List<MultipartFile> images) {
return IntStream.rangeClosed(FIRST_OPTION_SEQUENCE, postOptionContents.size())
.mapToObj(postOptionSequence ->
PostOption.of(
postOptionContents.get(postOptionSequence - 1),
this,
postOptionSequence,
images.get(postOptionSequence - 1)
)
)
.toList();
}

}

0 comments on commit 33b0609

Please sign in to comment.