package leigh.mecha.nodegraph;

import leigh.eo.EO;
import leigh.eo.EOLoop;

import java.io.Serializable;
import java.util.Objects;

public class GraphUtil {
    public static Serializable getValue(EO node, String key) {
        EOLoop values = node.getValueLoop(GraphSerializer.KEY_VALUES);
        for (EO value : values) {
            String valueKey = value.getValueString(GraphSerializer.KEY_NAME);
            if (Objects.equals(key, valueKey)) {
                return value.get(GraphSerializer.KEY_VALUE);
            }
        }
        return null;
    }
}
