package com.njcn.system.pojo.enums;


import lombok.Getter;

import java.util.Arrays;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2022年03月18日 13:27
 */
@Getter
public enum StatisticsEnum {

    /**
     * 统计类型字典枚举
     */
    POWER_NETWORK("网络拓扑", "Power_Network"),
    VOLTAGE_LEVEL("电压等级", "Voltage_Level"),
    LOAD_TYPE("干扰源类型", "Load_Type"),
    MANUFACTURER("终端厂家", "Manufacturer"),
    POWER_FLAG("监测点性质", "Power_Flag"),
    REPORT_TYPE("上报类型", "Report_Type"),
    JB_POWER_FLAG("电网性质", "Jb_Power_Flag"),

    ;

    private final String name;

    private final String code;

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


    /**
     * 没有匹配到，则默认为网络拓扑
     * @param code 统计类型code
     * @return 统计枚举实例
     */
    public static StatisticsEnum getStatisticsEnumByCode(String code) {
        return Arrays.stream(StatisticsEnum.values())
                .filter(statisticsEnum -> statisticsEnum.getCode().equalsIgnoreCase(code))
                .findAny()
                .orElse(POWER_NETWORK);
    }


}
