@Test public void shouldIncludePredicateInToStringRepresentation() throws Exception { Iterator<String> input = iteratorWith("1", "2", "3"); Predicate<String> predicate = new Predicate<String>() { public boolean evaluate(String item) { return item.contains("o"); } @Override public String toString() { return "the-predicate"; } }; FilteredIterator<String> iterator = new FilteredIterator<String>(input, predicate); String toString = iterator.toString(); assertThat(toString, containsString("the-predicate")); }
@Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("predicate", predicate) .toString(); }
FilteredIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("predicate", predicate) .toString(); } }
FilteredIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("predicate", predicate) .toString(); } FilteredIterator(Iterator<? extends T> iterator, UnaryPredicate<? super T> predicate); }
FilteredIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("predicate", predicate) .toString(); } FilteredIterator(Iterator<? extends T> iterator, UnaryPredicate<? super T> predicate); @Override String toString(); }
FilteredIterator extends CachingIterator<T> { @Override public String toString() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append("iterator", iterator) .append("predicate", predicate) .toString(); } FilteredIterator(Iterator<? extends T> iterator, UnaryPredicate<? super T> predicate); @Override String toString();  }