@Test public void shouldAllowNextToBeCalledWithoutHavingCalledHasNext() throws Exception { Range<Integer> range = new IntegerRange(0, 3); Iterator<Integer> iterator = range.iterator(); assertThat(iterator.next(), is(0)); assertThat(iterator.next(), is(1)); assertThat(iterator.next(), is(2)); }
@Override public Iterator<Integer> iterator() { if (start < end && step < 0 || start > end && step > 0) { return Iterators.emptyIterator(); } return new IntegerRangeIterator(); }
IntegerRange implements Range<Integer> { @Override public Iterator<Integer> iterator() { if (start < end && step < 0 || start > end && step > 0) { return Iterators.emptyIterator(); } return new IntegerRangeIterator(); } }
IntegerRange implements Range<Integer> { @Override public Iterator<Integer> iterator() { if (start < end && step < 0 || start > end && step > 0) { return Iterators.emptyIterator(); } return new IntegerRangeIterator(); } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); }
IntegerRange implements Range<Integer> { @Override public Iterator<Integer> iterator() { if (start < end && step < 0 || start > end && step > 0) { return Iterators.emptyIterator(); } return new IntegerRangeIterator(); } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); @Override boolean contains(Object other); @Override Integer getStart(); @Override Integer getEnd(); @Override Integer getStep(); @Override Iterator<Integer> iterator(); }
IntegerRange implements Range<Integer> { @Override public Iterator<Integer> iterator() { if (start < end && step < 0 || start > end && step > 0) { return Iterators.emptyIterator(); } return new IntegerRangeIterator(); } IntegerRange(Integer start, Integer end);  IntegerRange(Integer start, Integer end, Integer step); @Override boolean contains(Object other); @Override Integer getStart(); @Override Integer getEnd(); @Override Integer getStep(); @Override Iterator<Integer> iterator();  }