@Test public void shouldHaveNumberOfRepeatsAsInfiniteInTheToStringRepresentationIfNoneSupplied() throws Exception { Iterator<String> input = iteratorWith("1", "2", "3"); Iterator<String> iterator = new CyclicIterator<String>(input); String toString = iterator.toString(); assertThat(toString, containsString("numberOfTimesToRepeat=infinite")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("numberOfTimesToRepeat", numberOfTimesToRepeat == null ? "infinite" : numberOfTimesToRepeat) .append("numberOfRepeatsCompleted", repeats) .append("indexInCurrentRepeat", index) .toString(); }
CyclicIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("numberOfTimesToRepeat", numberOfTimesToRepeat == null ? "infinite" : numberOfTimesToRepeat) .append("numberOfRepeatsCompleted", repeats) .append("indexInCurrentRepeat", index) .toString(); } }
CyclicIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("numberOfTimesToRepeat", numberOfTimesToRepeat == null ? "infinite" : numberOfTimesToRepeat) .append("numberOfRepeatsCompleted", repeats) .append("indexInCurrentRepeat", index) .toString(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); }
CyclicIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("numberOfTimesToRepeat", numberOfTimesToRepeat == null ? "infinite" : numberOfTimesToRepeat) .append("numberOfRepeatsCompleted", repeats) .append("indexInCurrentRepeat", index) .toString(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString(); }
CyclicIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("numberOfTimesToRepeat", numberOfTimesToRepeat == null ? "infinite" : numberOfTimesToRepeat) .append("numberOfRepeatsCompleted", repeats) .append("indexInCurrentRepeat", index) .toString(); } CyclicIterator(Iterator<? extends T> iterator);  CyclicIterator(Iterator<? extends T> iterator, int numberOfTimesToRepeat); @Override boolean hasNext(); @Override T next(); @Override void remove(); @Override String toString();  }