package vismon.data;

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

public class MngAction {

    private Map<MngOption, Double>      action;

    public MngAction() {
        action = new HashMap<MngOption, Double>();
    }

    public MngAction(Map<MngOption, Double> v_s) {
        action = new HashMap<MngOption, Double>();
        action.putAll(v_s);
    }

    public double getMngValue(MngOption m) {
        return action.get(m);
    }

    public void addMngValue(MngOption m, double v) {
        action.put(m, v);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof MngAction) {
            MngAction action = (MngAction) obj;
            for (MngOption m : Session.getMngOptions())
                if (getMngValue(m) != action.getMngValue(m))
                    return false;
            return true;
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hCode = 0;
        for (Indicator ind : Session.getIndicators())
            hCode += action.get(ind);
        return hCode;
    }

    @Override
    public String toString() {
        return "(" +
            action.get(Session.getMngOption(0)) + ", " +
            action.get(Session.getMngOption(1)) + ")";
    }

}
