/** * Constructs a new <code>IteratorIterable</code> that will use the given * iterator. * * @param iterator the iterator to use. * @param multipleUse <code>true</code> if the new iterable can be used in multiple iterations */ public IteratorIterable(final Iterator<? extends E> iterator, final boolean multipleUse) { super(); if (multipleUse && !(iterator instanceof ResettableIterator)) { this.iterator = new ListIteratorWrapper<>(iterator); } else { this.iterator = iterator; } this.typeSafeIterator = createTypesafeIterator(this.iterator); }