List<List<CommittedChangeList>> (final List<CommittedChangeList> list, final int size) { final int listSize = list.size(); if (listSize < size) { return Collections.singletonList(list); } final int first = listSize % size; int start = 0; int end = (first == 0) ? (Math.min(listSize, size)) : first; final List<List<CommittedChangeList>> result = new ArrayList<>(listSize / size + 1); while (start < listSize) { result.add(list.subList(start, end)); start = end; end += size; } return result; }