public static <T> Iterator<T> unmodifiableIterator(Iterator<T> iterator) {

    Assert.notNull(iterator, "Iterator is required");

    return new Iterator<T>() {

      @Override
      public boolean hasNext() {
        return iterator.hasNext();
      }

      @Override
      public T next() {
        return iterator.next();
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException("Iterator is immutable");
      }
    };
  }
public static < T > Iterator < T > unmodifiableIterator ( Iterator < T > iterator ) { Assert . notNull ( iterator , "Iterator is required" ) ; return new Iterator < T > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public T next ( ) { return iterator . next ( ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( "Iterator is immutable" ) ; } } ; }
Returns an immutable {@link Iterator} implementation wrapping the given {@link Iterator} to prevent modifications
through invocations of the {@link Iterator#remove()} method.

@param <T> Class type of the elements in the {@link Iterator}.
@param iterator {@link Iterator} to make immutable.
@return an immutable {@link Iterator} implementation wrapping the given {@link Iterator}.
@throws IllegalArgumentException if {@link Iterator} is null.
@see java.util.Iterator