@Override
    public boolean hasNext() {
        switch (state) {
            case FAILED:
                throw new IllegalStateException("Iterator is in failed state");
            case DONE:
                return false;
            case READY:
                return true;
            default:
                return maybeComputeNext();
        }
    }
A base class that simplifies implementing an iterator
@param <T> The type of thing we are iterating over
clients/src/main/java/org/apache/kafka/common/utils/AbstractIterator.java