java convert list to page

www.la‮u‬tturi.com
java convert list to page

To convert a java.util.List object to a org.springframework.data.domain.Page object in Java, you can use the of method of the PageRequest class to create a PageRequest object, and then pass it to the Page constructor along with the List object.

Here is an example of how you can convert a java.util.List object to a org.springframework.data.domain.Page object in Java:

List<T> list = ...;
int pageNumber = ...;
int pageSize = ...;
PageRequest pageRequest = PageRequest.of(pageNumber, pageSize);
Page<T> page = Page.of(list, pageRequest);

In this example, we have a List object called list that contains the elements to be paginated, and two int variables called pageNumber and pageSize that specify the page number and page size, respectively. We use the PageRequest.of method to create a PageRequest object with the specified page number and page size, and pass it to the Page.of constructor along with the List object to create a Page object.

Created Time:2017-11-03 00:14:52  Author:lautturi