package com.cmvr.test.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 节点类型
 */
@Getter
@AllArgsConstructor
public enum NodeTypeEnum {

    START("start"),
    SUB_START("subStart"),
    FUNCTION("function"),
    BRANCH("branch"),
    LOOP("loop"),
    STOP_LOOP("stopLoop"),
    END("end"),
    SLEEP("sleep"),
    HTTP("http"),
    CODE("code"),
    GET_CURRENT_OBJECT("getCurrentObject"),
    SUB_END("subEnd"),
    ;

    private final String code;

    public static NodeTypeEnum fromRawType(String rawType) {
        switch (rawType.toLowerCase()) {
            case "start":
                return START;
            case "end":
                return END;
            case "branch":
                return BRANCH;
            case "loop":
                return LOOP;
            default:
                return FUNCTION;
        }
    }
}
