package com.diaoyun.zion.master.util;

import java.util.List;

/**
 * @Auther: wudepeng
 * @Date: 2019/11/23
 * @Description:
 */
public class ListUtil {
    public static List<String> pageBySubList(List list, int pageNum, int pageSize) {
        int totalcount = list.size();
        int pagecount = 0;
        List<String> subList;
        int m = totalcount % pageSize;
        if (m > 0) {
            pagecount = totalcount / pageSize + 1;
        } else {
            pagecount = totalcount / pageSize;
        }
        if (m == 0) {
            subList = list.subList((pageNum - 1) * pageSize, pageSize * (pageNum));
        } else {
            if (pageNum == pagecount) {
                subList = list.subList((pageNum - 1) * pageSize, totalcount);
            } else {
                subList = list.subList((pageNum - 1) * pageSize, pageSize * (pageNum));
            }
        }
        return subList;
    }
}
