package cn.axzo.workflow.common.enums;


import java.util.Arrays;
import java.util.Objects;

public enum BpmnFlowNodeType {

    //0 发起人 1审批 2抄送 3条件 4路由
    NODE_STARTER("NODE_STARTER", "发起人节点"),
    NODE_EXCLUSIVE_GATEWAY("NODE_EXCLUSIVE_GATEWAY", "排它网关"),
    NODE_CONDITION("NODE_CONDITION", "条件节点 - 隶属于排它网关"),
    NODE_PARALLEL_GATEWAY("NODE_PARALLEL_GATEWAY", "并行网关"),
    NODE_PARALLEL("NODE_PARALLEL", "并行节点 - 隶属于并行网关"),
    NODE_TASK("NODE_TASK", "审核节点"),
    NODE_BUSINESS("NODE_BUSINESS", "业务节点"),
    NODE_CARBON_COPY("NODE_CARBON_COPY", "抄送节点"),
    NODE_TRIGGER("NODE_TRIGGER", "触发器节点"),
    NODE_ROBOT("NODE_ROBOT", "机器人节点"),
    NODE_COMMENT("NODE_COMMENT", "评论节点"),
    NODE_ABORT("NODE_ABORT", "中止节点"),
    NODE_CANCEL("NODE_CANCEL", "撤回节点"),
    NODE_EMPTY("NODE_EMPTY", "空节点"),
    ;

    private String type;
    private String desc;

    BpmnFlowNodeType(String type, String desc) {
        this.type = type;
        this.desc = desc;
    }

    public boolean isEqual(String type) {
        return this.type.equals(type);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static BpmnFlowNodeType valueOfType(String type) {
        return Arrays.stream(BpmnFlowNodeType.values())
                .filter(i -> Objects.equals(i.getType(), type))
                .findAny()
                .orElse(null);
    }
}
