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 HardwareOperate implements BaseEnum<Integer> {

    OFFLINE(0, "离线"),
    EXCEPTION(1, "异常"),
    ONLINE(2, "在线"),
    OPEN(3,"打开"),
    CLOSE(4,"关闭"),
    ;


    private Integer code;
    private String name;

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

    public static HardwareOperate getByCode(Integer code) {
        return Arrays.stream(HardwareOperate.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;
    }

}
