package com.njcn.supervision.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * 用户性质枚举
 */
@Getter
public enum UserNatureEnum {

    BUILD_POWER_GRID(0, "新建电网工程"),
    EXTEND_POWER_GRID(1, "扩建电网工程"),

    BUILD_NON_LINEAR_LOAD(2, "新建非线性负荷用户"),
    EXTEND_NON_LINEAR_LOAD(3, "扩建非线性负荷用户"),
    BUILD_NEW_ENERGY_POWER_STATION(4, "新建新能源发电站"),
    EXTEND_NEW_ENERGY_POWER_STATION(5, "扩建新能源发电站"),

    SENSITIVE_USER(6, "敏感及重要用户");

    private final Integer code;

    private final String name;

    UserNatureEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public static String getNameByCode(Integer code) {
        for (UserNatureEnum userNatureEnum : UserNatureEnum.values()) {
            if (Objects.equals(userNatureEnum.code, code)) {
                return userNatureEnum.name;
            }
        }
        return "";
    }


    public static Integer getCodeByName(String name) {
        for (UserNatureEnum userNatureEnum : UserNatureEnum.values()) {
            if (userNatureEnum.name.equalsIgnoreCase(name)) {
                return userNatureEnum.code;
            }
        }
        return 0;
    }
}
