package com.github.twitch4j.common.util;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class CollectionUtils {

    public static <T> List<List<T>> chunked(Iterable<T> iterable, int size) {
        List<List<T>> chunks = new ArrayList<>();
        List<T> chunk = null;
        Iterator<T> it = iterable.iterator();
        for (int i = 0; it.hasNext(); i++) {
            if (i % size == 0) {
                chunk = new ArrayList<>();
                chunks.add(chunk);
            }

            chunk.add(it.next());
        }
        return chunks;
    }

}

@@ -67,33 +67,8 @@
 st;%0A
-import java.util.Arrays;%0A
 impo
@@ -90,16 +90,16 @@
 erator;%0A
+
 import j
@@ -146,16 +146,405 @@
 tils %7B%0A%0A
+    /**%0A     * Assigns elements of the given iterable to chunks not exceeding the desired size%0A     *%0A     * @param iterable the source of elements to be assigned to a chunk%0A     * @param size the maximum size of each chunk%0A     * @return a list of the chunks, or an empty list if the iterable yielded no elements%0A     * @throws NullPointerException if the passed iterable is null%0A     */%0A
     publ
@@ -813,24 +813,24 @@
 ize == 0) %7B%0A
-
             
@@ -849,32 +849,36 @@
 new ArrayList%3C%3E(
+size
 );%0A             

add javadoc for CollectionUtils.chunked and set initialCapacity