Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java convert list to page

// Remember that the list it has to not be already paged by the query

public Page<?> toPage(List<?> list, Pageable pageable) {
        int start = (int) pageable.getOffset();
        int end = Math.min((start + pageable.getPageSize()), list.size());
        if(start > list.size())
            return new PageImpl<>(new ArrayList<>(), pageable, list.size());
        return new PageImpl<>(list.subList(start, end), pageable, list.size());
    }
Comment

PREVIOUS NEXT
Code Example
Java :: java string format 2 decimal places 
Java :: cloning of list in java 
Java :: how to get index of second occurrence java 
Java :: how to print two variables in same line in java 
Java :: print two varaibles using one statement in java 
Java :: how to create a random number in java 
Java :: hibernate select count 
Java :: how to convert int array to integer list in java 
Java :: java if one sting on array match 
Java :: java random 5 digit int 
Java :: localdate add months in java 
Java :: java thread lambda 
Java :: how to check grant permissions in android 
Java :: java code to print hello world 
Java :: rewrite file java 
Java :: link to method javadoc 
Java :: clear array java 
Java :: get hashmap into array 
Java :: rjava error 
Java :: check if all values are same in list java 
Java :: how to generate random number in java 
Java :: all devisor of a number java 
Java :: java how to print a string[] 
Java :: what language is android written in 
Java :: java jframe example 
Java :: reflections java 
Java :: datetimeformatter for java 
Java :: how to add animation between activity in android 
Java :: close a popup selenium python 
Java :: set remove element java 
ADD CONTENT
Topic
Content
Source link
Name
4+8 =