Package com.aconex.scrutineer.elasticsearch

Source Code of com.aconex.scrutineer.elasticsearch.IdAndVersionInputStreamIterator

package com.aconex.scrutineer.elasticsearch;

import com.aconex.scrutineer.IdAndVersion;

import java.io.IOException;
import java.util.Iterator;

public class IdAndVersionInputStreamIterator implements Iterator<IdAndVersion> {

    private final IdAndVersionDataReader idAndVersionDataReader;
    private IdAndVersion currentValue;

    public IdAndVersionInputStreamIterator(IdAndVersionDataReader idAndVersionDataReader) {
        try {
            this.idAndVersionDataReader = idAndVersionDataReader;
            this.currentValue = idAndVersionDataReader.readNext();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public boolean hasNext() {
        return currentValue != null;
    }

    @Override
    public IdAndVersion next() {
        try {
            IdAndVersion result = currentValue;
            currentValue = idAndVersionDataReader.readNext();
            return result;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException();
    }
}
TOP

Related Classes of com.aconex.scrutineer.elasticsearch.IdAndVersionInputStreamIterator

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.