ChunkFilteredIterator implements Iterator<String> { @Override public String next() { if (null == nextItem) { nextItem = getNextFilteredItem(); } String item = nextItem; nextItem = getNextFilteredItem(); return item; } ChunkFilteredIterator(Iterator<String> iterator); @Override boolean hasNext(); @Override String next(); @Override void remove();  }
@Test public void testNext() throws Exception { space.add(item()); space.add(item()); space.add(item()); space.add(chunk()); space.add(chunk()); space.add(manifest()); space.add(item()); space.add(item()); iterator = new ChunkFilteredIterator(space.iterator()); Assert.assertEquals(space.get(0), iterator.next()); Assert.assertEquals(space.get(1), iterator.next()); Assert.assertEquals(space.get(2), iterator.next()); Assert.assertEquals(space.get(5), iterator.next() + manifestSuffix); Assert.assertEquals(space.get(6), iterator.next()); Assert.assertEquals(space.get(7), iterator.next()); Assert.assertNull(iterator.next()); }