package org.ut.cmldep.json.parser;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Iurii on 12/11/2014.
 */
public class NewConfiguration {

    public List<NodeConfiguration> getNewConfiguration() {
        return newConfiguration;
    }

    private List<NodeConfiguration> newConfiguration = new ArrayList<NodeConfiguration>();

    public NewConfiguration(JsonNode json) throws IOException {

        ObjectMapper mapper = new ObjectMapper();

        JsonNode arrNode = json.findValue("config");
        if (arrNode.isArray()) {
            for (final JsonNode objNode : arrNode) {
                newConfiguration.add(mapper.readValue(objNode, NodeConfiguration.class));
            }
        }
    }
}
