Skip to content

Commit

Permalink
Merge pull request #70 from opencb/TASK-1973
Browse files Browse the repository at this point in the history
TASK-1973 - Project limit not working
  • Loading branch information
pfurio authored Jan 23, 2023
2 parents e5e38a1 + bcc50ed commit 9d07470
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.opencb.commons.datastore.mongodb;

import com.mongodb.ServerAddress;
import com.mongodb.ServerCursor;
import com.mongodb.client.MongoCursor;
import org.bson.Document;
import org.opencb.commons.datastore.core.ComplexTypeConverter;
Expand All @@ -13,6 +15,8 @@ public class MongoDBIterator<E> implements Iterator<E>, Closeable {
private ComplexTypeConverter<E, Document> converter;
private long numMatches;

public static final EmptyMongoCursor<Document> EMPTY_MONGO_CURSOR_ITERATOR = new EmptyMongoCursor<>();

public MongoDBIterator(MongoCursor<Document> iterator, long numMatches) {
this(iterator, null, numMatches);
}
Expand Down Expand Up @@ -49,4 +53,40 @@ public void close() {
iterator.close();
}
}

private static class EmptyMongoCursor<T> implements MongoCursor<T> {

EmptyMongoCursor() {
}

@Override
public void close() {
}

@Override
public boolean hasNext() {
return false;
}

@Override
public T next() {
return null;
}

@Override
public T tryNext() {
return null;
}

@Override
public ServerCursor getServerCursor() {
return null;
}

@Override
public ServerAddress getServerAddress() {
return null;
}
}

}

0 comments on commit 9d07470

Please sign in to comment.