import java.util.*;public class CollectionUtil { /** * 对List进行分页处理 * @param list 需要分页的List * @param pageSize 单页条数 * @param pageNum 页码 */ public staticList pageList(List list, int pageSize, int pageNum) { if (list == null || list.isEmpty()) { return list; } int offset = (pageNum - 1) * pageSize; int size = Math.min(pageNum * pageSize, list.size()); if (offset > size) { return Collections.emptyList(); } return list.subList(offset, size); } /** * 匹配Map中是否存在key,忽略大小写 * @param map 要遍历的Map * @param key 要匹配的Key * @return 命中Map中的Key */ public static String matchKeyIgnoreCase(Map map, String key) { if (map == null || map.isEmpty() || key == null) { return null; } for (String mapKey : map.keySet()) { if (mapKey.equalsIgnoreCase(key)) { return mapKey; } } return null; } /** * 对List元素去重 */ public static List uniqueList(List list) { if (list == null || list.isEmpty()) { return list; } Set set = new HashSet<>(list); list.clear(); list.addAll(set); return list; }}