All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.venmo.cursor.CursorIterator Maven / Gradle / Ivy

There is a newer version: 0.4
Show newest version
package com.venmo.cursor;

import java.util.Iterator;

/**
 * Default iterator for all {@link IterableCursor}s.
 */
public class CursorIterator implements Iterator {

    private IterableCursor mCursor;

    public CursorIterator(IterableCursor cursor) {
        mCursor = cursor;
    }

    @Override
    public boolean hasNext() {
        return !mCursor.isBeforeFirst() && !mCursor.isAfterLast();
    }

    @Override
    public T next() {
        return mCursor.nextDocument();
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Cannot remove an object in a cursor");
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy