package com.bocloud.cmp.entity.enums.jumpserver;

public enum AccessMethod {
    RDP("gui", "rdp", 3389),
    SSH("term", "ssh", 22),
    TELNET("term", "telnet", 177),
    TN5250("term", "tn5250", 23),
    XFWD("gui", "xfwd", null),// 没有端口, "xfwd_cmdline": "xterm"
    XDMCP("gui", "xdmcp", 177),
    VNC("gui", "vnc", 5900),
    ;
    private final String type;
    private final String value;
    private final Integer port;

    AccessMethod(String type, String value, Integer port) {
        this.type = type;
        this.value = value;
        this.port = port;
    }

    public static AccessMethod byValue(String value) {
        for (AccessMethod per : AccessMethod.values()) {
            if (per.value.equals(value)) {
                return per;
            }
        }
        return null;
    }

    public static AccessMethod byType(String type) {
        for (AccessMethod per : AccessMethod.values()) {
            if (per.type.equals(type)) {
                return per;
            }
        }
        return null;
    }

    public String getValue() {
        return value;
    }

    public String getType() {
        return type;
    }

    public Integer getPort() {
        return port;
    }
}
