View Javadoc

1   package net.sourceforge.pmd.util;
2   
3   import java.util.Iterator;
4   
5   /**
6    * A singleton iterator that never has anything.
7    * 
8    * @author Brian Remedios
9    *
10   * @param <T>
11   */
12  @SuppressWarnings("rawtypes")
13  public class EmptyIterator<T extends Object> implements Iterator<T> {
14  
15  	public static final Iterator instance = new EmptyIterator();
16  	
17  	private EmptyIterator() {}
18  	
19  	public boolean hasNext() { return false; }
20  
21  	public T next() { return null;	}
22  
23  	public void remove() {	
24  		throw new UnsupportedOperationException();
25  	}
26  };