public static <E> Iterator<E> decorate(Iterator<E> iterator) {
        if (iterator == null) {
            throw new IllegalArgumentException("Iterator must not be null");
        }
        if (iterator instanceof Unmodifiable) {
            return iterator;
        }
        return new UnmodifiableIterator<E>(iterator);
    }
Decorates the specified iterator such that it cannot be modified.
<p/>
If the iterator is already unmodifiable it is returned directly.

@param iterator the iterator to decorate
@throws IllegalArgumentException if the iterator is null
jphp-runtime/src/php/runtime/common/collections/iterators/UnmodifiableIterator.java