class Aggregator {

    public void addItem(T item)
    {
        if (myBatchSize > 1)
        {
            myItems.add(item);
            if (myItems.size() >= myBatchSize)
            {
                processAll();
            }
        }
        else
        {
            myProcessor.accept(Collections.singletonList(item));
        }
    }

    public  Aggregator(int batchSize, Consumer<List<T>> processor);

}