* is {@code null} * @return the batched list, which may be a sublist per {@link List#subList} */ public static <T> BatchedList<T> getBatchedList(List<T> list, BigInteger maxItems, BigInteger skipCount, int defaultMax) { int skip = skipCount == null ? 0 : skipCount.intValue(); if (skip < 0) { skip = 0; } int max = maxItems == null ? -1 : maxItems.intValue(); if (max < 0) { max = defaultMax; } BatchedList<T> res = new BatchedList<T>(); res.setNumItems(list.size()); if (skip >= list.size()) { res.setHasMoreItems(false); res.setList(Collections.<T> emptyList()); return res; }