@Override
    public T next() {
        try {
            Document document;
            if (fieldSelector != null) {
                document = searcher.doc(scoreDocs[cursor++].doc, fieldSelector);
            } else {
                document = searcher.doc(scoreDocs[cursor++].doc);
            }
            return transformer.apply(document);
        } catch (IOException e) {
            throw new QueryException(e);
        }
    }
{@code ResultIterator} is a {@link CloseableIterator} implementation for Lucene query results

@author tiwe

@param <T>
querydsl-lucene3/src/main/java/com/querydsl/lucene3/ResultIterator.java