@Test @SuppressWarnings("unchecked") public void shouldIncludeIteratorInToStringRepresentation() throws Exception { Iterator<Integer> input = (Iterator<Integer>) mock(Iterator.class); UnaryFunction<Integer, Integer> mapper = UnaryFunctions.identity(); when(input.toString()).thenReturn("the-iterator"); MappedIterator<Integer, Integer> iterator = new MappedIterator<Integer, Integer>(input, mapper); String toString = iterator.toString(); assertThat(toString, containsString("the-iterator")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); }
MappedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); } }
MappedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); } MappedIterator(Iterator<? extends S> iterator, UnaryFunction<? super S, ? extends T> mapper); }
MappedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); } MappedIterator(Iterator<? extends S> iterator, UnaryFunction<? super S, ? extends T> mapper); boolean hasNext(); T next(); void remove(); @Override String toString(); }
MappedIterator implements Iterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("mappingFunction", function) .toString(); } MappedIterator(Iterator<? extends S> iterator, UnaryFunction<? super S, ? extends T> mapper); boolean hasNext(); T next(); void remove(); @Override String toString();  }