public static <T> Collector<T, List<T>, List<T>> batchCollector(int batchSize, Consumer<List<T>> batchProcessor) {
        return new BatchCollector<>(batchSize, batchProcessor);
    }
@Test
    void canBatch() {
        List<Integer> input = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
        List<Integer> output = new ArrayList<>();

        int batchSize = 3;
        Consumer<List<Integer>> batchProcessor = xs -> {
            System.out.println("Adding " + xs.size());
            output.addAll(xs);
        };

        input.stream()
                .collect(batchCollector(batchSize, batchProcessor));

        assertThat(output).containsExactly(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    }