Hello!
I'm currently working with CursorResult and CursorRawResult classes. Both of them implement the Iterable interface, enabling us to iterate more than once over the result.
However, the iterator method returns always the same iterator and thus the result can only be consumed once.
@Override
public Iterator<T> iterator() {
if (iter == null) {
iter = new CursorIterator();
}
return iter;
}
It makes perfectly sense that the result can only be consumed once, because the cursor of the DB is also moved with continueQuery method. One could aggregate the results instead of overwriting it and always provide a new iterator. But the list can grow huge and there is also the asList method.
Wouldn't it be more clear for the user if CursorResult and CursorRawResult would implement the Iterator interface, indicating that it can only be consumed once?
And the asList method returns only a complete list if no object is already consumed from the iterator. Should the asList method be called asListRemaining just like the forEachRemaining of the Iterator interface? Or completely remove this method to avoid confusing?