code: public static <E> CloseableIterator<E> iterator(Iterator<? extends E> iterator) {
        if (iterator instanceof CloseableIterator) {
           return (CloseableIterator<E>) iterator;
        }
        return new IteratorAsCloseableIterator<>(iterator);
     }
docs: Creates a closeable iterator from the given iterator that does nothing when close is called.
  @param iterator The iterator to wrap to allow it to become a closeable iterator
  @param <E> The type of the iterators
  @return An iterator that does nothing when closed