package com.xhpc.common.enums;

/**
 * 电桩类型
 */
public enum PowerTypeEnum {

    DC(1, "直流"),
    AC(2, "交流"),
    ;

    private final int code;
    private final String name;

    PowerTypeEnum(int code, String name){
        this.code = code;
        this.name = name;
    }

    //根据code获取name
    public static String getNameByCode(int code) {
        for (PowerTypeEnum typeEnum : PowerTypeEnum.values()) {
            //移除交办
            if (typeEnum.code == code) {
                return typeEnum.name;
            }
        }
        return "";
    }

    //根据code获取name
    public static Integer getCodeByName(String name) {
        for (PowerTypeEnum typeEnum : PowerTypeEnum.values()) {
            //移除交办
            if (typeEnum.name.equals(name)) {
                return typeEnum.code;
            }
        }
        return null;
    }

    public int getCode() {

        return code;
    }

    public String getName() {

        return name;
    }
}
