package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.valid.ValidEunm;

import java.util.Arrays;

/**
 * 危险源类型
 *
 * @Author: zhoupan
 * @Date: 2021/09/10/8:59
 * @Description:
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum HazardTypeEnum implements ValidEunm, BaseEnum<Integer> {
    HAZARD(0, "危险品"),
    CONTAINER(1, "压力容器"),
    ;

    private Integer code;
    private String name;

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

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

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    @Override
    public String codes() {
        return this.code.toString();
    }

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