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

se.l4.silo.results.IteratorFetchResult Maven / Gradle / Ivy

The newest version!
package se.l4.silo.results;

import java.util.Collection;
import java.util.Iterator;

import se.l4.silo.FetchResult;

/**
 * {@link FetchResult} implemented over an {@link Iterator}.
 *
 * @author Andreas Holstenson
 *
 * @param 
 */
public class IteratorFetchResult
	implements FetchResult
{
	private Iterator it;
	private long size;
	private long offset;
	private long limit;
	private long total;

	public IteratorFetchResult(Iterator it, long size, long offset, long limit, long total)
	{
		this.it = it;
		this.size = size;
		this.offset = offset;
		this.limit = limit;
		this.total = total;
	}

	public IteratorFetchResult(Collection data, long offset, long limit, long total)
	{
		this(data.iterator(), data.size(), offset, limit, total);
	}

	@Override
	public Iterator iterator()
	{
		return it;
	}

	@Override
	public long getSize()
	{
		return size;
	}

	@Override
	public long getOffset()
	{
		return offset;
	}

	@Override
	public long getLimit()
	{
		return limit;
	}

	@Override
	public long getTotal()
	{
		return total;
	}

	@Override
	public boolean isEmpty()
	{
		return size == 0;
	}

	@Override
	public void close()
	{

	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy