Last active
June 15, 2020 14:09
-
-
Save vbmendes/19729cc88f6488b25e3c5eb9ec4ed2e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class PaginationUtil { | |
private PaginationUtil(){} | |
public static <T> Page<T> paginateList(final Pageable pageable, List<T> list) { | |
int first = Math.min(new Long(pageable.getOffset()).intValue(), list.size());; | |
int last = Math.min(first + pageable.getPageSize(), list.size()); | |
return new PageImpl<>(list.subList(first, last), pageable, list.size()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment