package org.bdware.sc.bean;

import org.bdware.sc.node.AnnotationNode;
import org.bdware.sc.node.ContractNode;
import org.bdware.sc.util.JsonUtil;

import java.io.Serializable;

public class JoinInfo implements Serializable {
    public DefaultJoinRule joinRule;

    public static JoinInfo create(AnnotationNode annotationNode, ContractNode contractNode) {
        JoinInfo info = new JoinInfo();
        info.joinRule = null;
        if (annotationNode.getArgs().size() == 1) {
            switch (annotationNode.getArgs().get(0)) {
                case "add":
                    info.joinRule = DefaultJoinRule.add;
                    break;
                case "multiply":
                    info.joinRule = DefaultJoinRule.multiply;
                    break;
            }
        }
        System.out.println("[JoinInfo] annotationNode:" + JsonUtil.toJson(annotationNode));
        return info;
    }
}
