package org.ut.cmldep.json.parser;

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

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

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

    private String name;

    public List<InstanceToCreate> getInstances() {
        return instances;
    }

    public void setInstances(List<InstanceToCreate> instances) {
        this.instances = instances;
    }

    private List<InstanceToCreate> instances;

    public NodeConfiguration(String name, JsonNode json) throws IOException {
        ObjectMapper mapper = new ObjectMapper();
        this.name = name;
        this.instances = mapper.readValue(
                json,
                mapper.getTypeFactory().constructCollectionType(
                        List.class, InstanceToCreate.class));
    }

    public NodeConfiguration(){

    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
