/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package API;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author Eugenio
 */
public class BuildParams {

    public static HashMap<String, ArrayList<String>> params = new HashMap<>();

    public static void _init() {
    }

    public static void Set(String tag, ArrayList<String> values) {
        params.put(tag, values);
    }

    public static String GetFirst(String tag) throws Exception {
        return Get(tag).get(0);
    }

    public static ArrayList<String> Get(String tag) throws Exception {
        if (!params.containsKey(tag)) {
            throw new Exception(String.format("Build param `%s` não definido!", tag));
        }
        return params.get(tag);
    }

    public static void Add(String tag, String value) {
        ArrayList<String> container;

        if (!params.containsKey(tag)) {
            container = new ArrayList<>();
            params.put(tag, container);
        } else {
            container = params.get(tag);
        }
        container.add(value);
    }

    public static void Set(String tag, String value) {
        ArrayList<String> a = new ArrayList<>();
        a.add(value);
        params.put(tag, a);
    }

    public static void List() {
        System.out.println("BuildParams:\n");
        for (Map.Entry<String, ArrayList<String>> entry : params.entrySet()) {
            System.out.println(entry.getKey() + ": " + entry.getValue());
        }
    }

}
