1 // Copyright 2009 Google Inc. All Rights Reserved.
2 package com
.google
.appengine
.api
.datastore
;
4 import java
.util
.Iterator
;
5 import java
.util
.NoSuchElementException
;
8 * @see com.google.common.collect.AbstractIterator
10 abstract class AbstractIterator
<T
> implements Iterator
<T
> {
11 private State state
= State
.NOT_READY
;
22 protected abstract T
computeNext();
24 protected final T
endOfData() {
30 public final boolean hasNext() {
31 if (state
== State
.FAILED
) {
32 throw new IllegalStateException();
41 return tryToComputeNext();
44 private boolean tryToComputeNext() {
47 if (state
!= State
.DONE
) {
55 public final T
next() {
57 throw new NoSuchElementException();
59 state
= State
.NOT_READY
;
64 public void remove() {
65 throw new UnsupportedOperationException();