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

fr.adbonnin.cz2128.json.iterator.ValueArrayIterator Maven / Gradle / Ivy

The newest version!
package fr.adbonnin.cz2128.json.iterator;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.ObjectReader;
import fr.adbonnin.cz2128.json.JsonException;

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

import static java.util.Objects.requireNonNull;

public class ValueArrayIterator implements Iterator {

    private final ArrayIterator iterator;

    private final ObjectReader reader;

    public ValueArrayIterator(JsonParser parser, ObjectReader reader) {
        this.reader = requireNonNull(reader);
        this.iterator = new ArrayIterator(parser);
    }

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

    @Override
    public E next() {
        try {
            return reader.readValue(iterator.next());
        }
        catch (IOException e) {
            throw new JsonException(e);
        }
    }

    @Override
    public void remove() {
        iterator.remove();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy