docs: private static <E> List<E> getBatchList(Integer index, int batchSize, Collection<E> collection) {
          List<E> list = null;
          if (collection instanceof List) {
              list = (List<E>) collection;
          } else {
              list = new ArrayList<E>(collection);
          }
  
          if (index == list.size() / batchSize) {
              return list.subList(index * batchSize, list.size());
          } else {
              return list.subList(index * batchSize, (index + 1) * batchSize);
          }
      }