Skip to content

Commit

Permalink
refactor(pagination): list null 체크 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
jminkkk committed Nov 12, 2024
1 parent 34b7613 commit 514f9f1
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package codezap.global.pagination;

import java.util.Objects;

import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

Expand All @@ -21,12 +19,12 @@ public int countNextFixedPage(
BooleanExpression... conditions
) {
int maximumElementsCount = pageable.getPageSize() * MAXIMUM_PAGE;
long nextFixedElementCounts = Objects.requireNonNull(queryFactory
.selectFrom(entityPath)
.where(conditions)
.offset(pageable.getOffset())
.limit(maximumElementsCount)
.fetch())
long nextFixedElementCounts = queryFactory
.selectFrom(entityPath)
.where(conditions)
.offset(pageable.getOffset())
.limit(maximumElementsCount)
.fetch()
.size();

return (int) Math.ceil((double) nextFixedElementCounts / pageable.getPageSize());
Expand Down

0 comments on commit 514f9f1

Please sign in to comment.