Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Ternary ifs and less nesting.

Related: GH-3094
Original pull request: GH-2865
  • Loading branch information
odrotbohm committed May 14, 2024
1 parent ae76d08 commit b09c503
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,12 @@ public Pageable resolveArgument(MethodParameter methodParameter, @Nullable Model
Sort sort = sortResolver.resolveArgument(methodParameter, mavContainer, webRequest, binderFactory);
Pageable pageable = getPageable(methodParameter, page, pageSize);

if (sort.isSorted()) {
if (pageable.isPaged()) {
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
}
else {
pageable = Pageable.unpaged(sort);
}
if (!sort.isSorted()) {
return pageable;
}

return pageable;
return pageable.isPaged()
? PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort)
: Pageable.unpaged(sort);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,12 @@ public Pageable resolveArgumentValue(MethodParameter parameter, BindingContext b
Sort sort = sortResolver.resolveArgumentValue(parameter, bindingContext, exchange);
Pageable pageable = getPageable(parameter, page, pageSize);

if (sort.isSorted()) {
if (pageable.isPaged()) {
pageable = PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort);
}
else {
pageable = Pageable.unpaged(sort);
}
if (!sort.isSorted()) {
return pageable;
}

return pageable;
return pageable.isPaged()
? PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), sort)
: Pageable.unpaged(sort);
}
}

0 comments on commit b09c503

Please sign in to comment.