1 package org.hibernate.util; 3 4 import java.util.Iterator ; 5 6 9 public final class SingletonIterator implements Iterator { 10 11 private Object value; 12 private boolean hasNext = true; 13 14 public boolean hasNext() { 15 return hasNext; 16 } 17 18 public Object next() { 19 if (hasNext) { 20 hasNext = false; 21 return value; 22 } 23 else { 24 throw new IllegalStateException (); 25 } 26 } 27 28 public void remove() { 29 throw new UnsupportedOperationException (); 30 } 31 32 public SingletonIterator(Object value) { 33 this.value = value; 34 } 35 36 } 37 | Popular Tags |