package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.Arrays;

/**
 * @Author: zhoupan
 * @Date: 2021/09/13/14:41
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum SenseStateEnum implements BaseEnum<Integer> {

    OFFLINE(0, "离线"),
    TURN_ON(1, "在线"),
    ERROR(2, "异常"),
    ;

    private Integer code;
    private String name;

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

    public static SenseStateEnum getByCode(Integer code) {
        return Arrays.stream(SenseStateEnum.values()).filter(a -> a.code.equals(code)).findFirst().orElse(null);
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public Integer getDictKey() {
        return code;
    }

}
