@Test public void shouldIncludeCursorInToStringRepresentation() throws Exception { Iterator<Integer> input = iteratorWith(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); Integer start = 2, stop = 7, step = 2; SubSequenceIterator<Integer> iterator = new SubSequenceIterator<Integer>(input, start, stop, step); Integer val = iterator.next(); String toString = iterator.toString(); assertThat(toString, containsString("cursor=3")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); }
SubSequenceIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); } }
SubSequenceIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); } SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop, Integer step);  SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop); }
SubSequenceIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); } SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop, Integer step);  SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop); @Override String toString(); }
SubSequenceIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("start", start) .append("stop", stop) .append("step", step) .append("cursor", cursor) .toString(); } SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop, Integer step);  SubSequenceIterator(Iterator<? extends T> iterator, Integer start, Integer stop); @Override String toString();  }