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

com.eightkdata.mongowp.server.api.pojos.SimpleBatch Maven / Gradle / Ivy

There is a newer version: 0.50.0
Show newest version

package com.eightkdata.mongowp.server.api.pojos;

import com.eightkdata.mongowp.server.api.pojos.MongoCursor.Batch;
import com.google.common.collect.Lists;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

/**
 *
 */
public class SimpleBatch implements Batch {
    private final Iterator it;
    private final int batchSize;
    private final long fetchTime;

    public SimpleBatch(Collection collection, long fetchTime) {
        this.it = collection.iterator();
        batchSize = collection.size();
        this.fetchTime = fetchTime;
    }

    public SimpleBatch(Iterator it, int batchSize, long fetchTime) {
        this.it = it;
        this.batchSize = batchSize;
        this.fetchTime = fetchTime;
    }

    @Override
    public void remove() throws UnsupportedOperationException {
        throw new UnsupportedOperationException("Not supported.");
    }

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

    @Override
    public boolean hasNext() {
        return it.hasNext();
    }

    @Override
    public int getBatchSize() {
        return batchSize;
    }

    @Override
    public long getFetchTime() {
        return fetchTime;
    }

    @Override
    public List asList() {
        return Lists.newArrayList(it);
    }

    @Override
    public void close() {
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy