@Test public void whenNextFourTimesThenResultFour() { final Integer expected = 4; convertedIterator.next(); convertedIterator.next(); convertedIterator.next(); Integer result = convertedIterator.next(); assertThat(result, is(expected)); }
@Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; } }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  @Override Iterator<Integer> convert(Iterator<Iterator<Integer>> it); @Override boolean hasNext(); @Override Integer next(); }
ConverterIterator implements Iterator<Integer>, Converter { @Override public Integer next() { Integer result; if (currentIterator.hasNext()) { result = currentIterator.next(); } else if (iterators.hasNext()) { currentIterator = iterators.next(); result = currentIterator.next(); } else { throw new NoSuchElementException("No numbers in iterators."); } return result; }  @Override Iterator<Integer> convert(Iterator<Iterator<Integer>> it); @Override boolean hasNext(); @Override Integer next();  }