SplitHandler implements SampleVisitor<T> { @Override public void finish() { checkInit(); for (int i = 0; i < segments; ++i) { SegmentBuffer<T> buffer = buffers.get(i); T segment = buffer.last(); int count = buffer.lastCount(); if (count > 0) handle(i, segment, count); } } SplitHandler(Splitter<T> splitter); @Override void init(); @Override void finish(); @Override List<? extends T> visit(T input);  }
@Test(expected = IllegalStateException.class) public void finishBeforeInit() { ToArraySplitHandler handler = new ToArraySplitHandler(new BucketTestUtils.SingletonSplitter<String>()); handler.finish(); }