DefeatTypeEnum.java 1.02 KB
package cn.fw.valhalla.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import lombok.Getter;

/**
 * @author : kurisu
 * @className : DefeatTypeEnum
 * @description : 战败类型
 * @date: 2020-10-16 17:56
 */
public enum DefeatTypeEnum {
    /**
     * 主动战败
     */
    A(1, "主动战败"),
    /**
     * 到期划走
     */
    B(2, "到期划走"),
    /**
     * 到期战败
     */
    C(3, "到期战败");

    /**
     * 值
     */
    private final Integer value;
    /**
     * 名称
     */
    @Getter
    private final String name;

    DefeatTypeEnum(final Integer value, final String name) {
        this.value = value;
        this.name = name;
    }

    /**
     * 根据枚举值获取枚举对象
     */
    @JsonCreator
    public static DefeatTypeEnum ofValue(final Integer value) {
        for (final DefeatTypeEnum typeEnum : DefeatTypeEnum.values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum;
            }
        }
        return null;
    }
}