@Override
    public T next() {
        if (!hasNext())
            throw new NoSuchElementException();
        state = State.NOT_READY;
        if (next == null)
            throw new IllegalStateException("Expected item but none found.");
        return next;
    }
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