package leigh.eo.io;

import leigh.eo.EO;

import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.Queue;

public class QueueEOInputStream implements EOInputStream {
    private final Queue<EO> queue;

    public QueueEOInputStream(Queue<EO> queue) {
        this.queue = queue;
    }

    @Override
    public EO readEo() throws IOException {
        try {
            return queue.remove();
        } catch (NoSuchElementException e) {
            return null;
        }
    }

    @Override
    public void close() throws Exception {
        // NOP
    }
}
