All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gccloud.starter.common.utils.PageUtils Maven / Gradle / Ivy

package com.gccloud.starter.common.utils;

import java.util.ArrayList;
import java.util.List;

public class PageUtils {

    /**
     * 处理List集合数据进行分页
     *
     * @param currentPage 当前页
     * @param pageSize    每页数据个数
     * @param list        进行分页的数据
     * @param 
     * @return
     */
    public static  List getPageInfo(int currentPage, int pageSize, List list) {
        List newList = new ArrayList<>();
        if (list != null && list.size() > 0) {
            int currIdx = (currentPage > 1 ? (currentPage - 1) * pageSize : 0);
            for (int i = 0; i < pageSize && i < list.size() - currIdx; i++) {
                newList.add(list.get(currIdx + i));
            }
        }
        return newList;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy