class AutoClosableCursorIterator<T> implements Iterator<T> {
    /** Cursor. */
    private final QueryCursor cursor;

    /** Iterator. */
    private final Iterator<T> iter;

    /**
     * Constructor.
     *
     * @param cursor Query cursor.
     * @param iter Wrapped iterator.
     */
    public AutoClosableCursorIterator(QueryCursor cursor, Iterator<T> iter) {
        this.cursor = cursor;
        this.iter = iter;
    }

    /** {@inheritDoc} */
    @Override public boolean hasNext() {<FILL_FUNCTION_BODY>}

    /** {@inheritDoc} */
    @Override public T next() {
        return iter.next();
    }
}

        boolean hasNext = iter.hasNext();

        if (!hasNext)
            cursor.close();

        return hasNext;
    
<no_super_class>