CheckedIterator { @NonNull public <NEW> CheckedIterator<NEW, T> transform(@NonNull final Function<? super E, ? extends NEW> function) { requireNonNull(function); final CheckedIterator<E, T> iterator = this; return new CheckedIterator<NEW, T>() { @Override public boolean hasNext() throws T { return iterator.hasNext(); } @Override public NEW next() throws T, NoSuchElementException { return function.apply(iterator.next()); } }; }  abstract boolean hasNext(); @Nullable abstract E next(); @Nullable E next(@Nullable E defaultValue); int count(); boolean copyInto(@NonNull Collection<? super E> collection); @NonNull List<E> toList(); @NonNull E[] toArray(@NonNull Class<E> type); @NonNull Map<E, V> toMap(@NonNull Function<? super E, V> valueFunc); @NonNull Map<K, V> toMap(@NonNull Function<? super E, K> keyFunc, @NonNull Function<? super E, V> valueFunc); @Nullable E getLast(); @Nullable E getLast(@Nullable E defaultValue); @Nullable E get(int position); @Nullable E get(int position, @Nullable E defaultValue); boolean all(@NonNull Predicate<? super E> predicate); boolean any(@NonNull Predicate<? super E> predicate); int indexOf(@NonNull Predicate<? super E> predicate); boolean contains(@Nullable E element); boolean elementsEqual(@NonNull CheckedIterator<E, T> that); @Nullable E find(@NonNull Predicate<? super E> predicate); @Nullable E find(@NonNull Predicate<? super E> predicate, @Nullable E defaultValue); int frequency(@Nullable E element); @NonNull CheckedIterator<E, T> filter(@NonNull final Predicate<? super E> predicate); @NonNull CheckedIterator<E, T> filter(@NonNull Class<? extends E> type); @NonNull CheckedIterator<E, T> skip(final int skipSize); @NonNull CheckedIterator<E, T> limit(final int limitSize); @NonNull CheckedIterator<NEW, T> transform(@NonNull final Function<? super E, ? extends NEW> function); @NonNull CheckedIterator<E, T> concat(@NonNull CheckedIterator<E, T> input); @NonNull static CheckedIterator<E, T> emptyIterator(); @NonNull static CheckedIterator<X, RuntimeException> fromIterator(@NonNull final Iterator<X> iterator); @NonNull static CheckedIterator<String, IOException> fromBufferedReader(@NonNull final BufferedReader reader);  }
@Test public void testTransform() { CheckedIterator<String, RuntimeException> iterator; iterator = create("one", "two", "three").transform(o -> "hello"); assertArrayEquals(new String[]{"hello", "hello", "hello"}, iterator.toList().toArray()); }