/** * 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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(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 */ public static Iterator decorate(Iterator iterator) { if (iterator == null) { throw new IllegalArgumentException("Iterator must not be null"); } if (iterator instanceof Unmodifiable) { return iterator; } return new UnmodifiableIterator(iterator); }