Skip to content

Commit

Permalink
feat: Collectors.toMap 사용 시 순서 보장을 위한 LinkedHashMap 적용 (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdkdhoho committed Feb 4, 2024
1 parent e198c6e commit 7426084
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.listywave.user.application.domain.User;
import com.listywave.user.repository.UserRepository;
import jakarta.transaction.Transactional;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.RequiredArgsConstructor;
Expand Down Expand Up @@ -50,9 +51,11 @@ public CommentFindResponse getComments(Long listId, int size, Long cursorId) {
Map<Comment, List<Reply>> result = comments.stream()
.collect(toMap(
identity(),
replyRepository::getAllByComment
replyRepository::getAllByComment,
(exists, newValue) -> exists,
LinkedHashMap::new
));

Long cursorIdOfResult = comments.get(comments.size() - 1).getId();
boolean hasNext = comments.size() >= size;

Expand Down

0 comments on commit 7426084

Please sign in to comment.