BizUtils.java 494 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package com.tanpu.community.util;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang3.StringUtils;

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

public class BizUtils {

    public static <T> List<T> subList(List<T> list, int start, int size) {
        if (list.isEmpty() || start >= list.size() || start < 0) {
            return new ArrayList<>();
        }
        int realEnd = Math.min(start + size, list.size());
        return list.subList(start, realEnd);
    }
}