package de.bwaldvogel.mongo.backend;

import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;

import de.bwaldvogel.mongo.bson.Document;

public class Cursor implements Iterable<Document> {

    public static final long EMPTY_CURSOR_ID = 0L;

    private final long cursorId;
    private final Queue<Document> documents = new LinkedList<>();

    public Cursor(Iterable<Document> documents, long cursorId) {
        this.cursorId = cursorId;
        for (Document document : documents) {
            this.documents.add(document);
        }
    }

    public Cursor() {
        this(Collections.emptyList(), EMPTY_CURSOR_ID);
    }

    public int documentsCount() {
        return documents.size();
    }

    public boolean isEmpty() {
        return documents.isEmpty();
    }

    public long getCursorId() {
        return cursorId;
    }

    public Document pollDocument() {
        return documents.poll();
    }

    @Override
    public Iterator<Document> iterator() {
        return documents.iterator();
    }

    @Override
    public String toString() {
        return getClass().getSimpleName() + "(id: " + cursorId + ")";
    }
}

@@ -65,35 +65,8 @@
 ns;%0A
-import java.util.Iterator;%0A
 impo
@@ -181,38 +181,8 @@
 rsor
- implements Iterable%3CDocument%3E
  %7B%0A%0A
@@ -915,109 +915,8 @@
  %7D%0A%0A
-    @Override%0A    public Iterator%3CDocument%3E iterator() %7B%0A        return documents.iterator();%0A    %7D%0A%0A
     

Remove unused interface of Cursor