package com.njcn.csdevice.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * @author xuyang
 */

@Getter
public enum LineBaseEnum {

    /**
     * 治理终端树结构
     */
    ENGINEERING_LEVEL(0, "工程"),
    PROJECT_LEVEL(1, "项目"),
    DEVICE_LEVEL(2, "设备"),
    LINE_LEVEL(3, "监测点"),
    INVALID_LEVEL(-1, "非法拓扑等级"),
    NOWLRECORD_FAIL(-1,"方案ID不存在"),
    EXISTWLRECORD_FAIL(-1,"方案名称已存在"),
    DEVID_FAIL(-1,"devId有误"),
    NOTYPE_FAIL(-1,"devId有误"),
    ;

    private final Integer code;
    private final String message;

    LineBaseEnum(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static com.njcn.csdevice.enums.LineBaseEnum getLineBaseEnumByCode(Integer code) {
        return Arrays.stream(com.njcn.csdevice.enums.LineBaseEnum.values())
                .filter(lineBaseEnum -> lineBaseEnum.getCode().equals(code))
                .findAny()
                .orElse(INVALID_LEVEL);
    }

}
