CallTypeEnum.java 1.55 KB
package cn.fw.valhalla.domain.enums;

import com.baomidou.mybatisplus.core.enums.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

/**
 * @author : kurisu
 * @className : CallTypeEnum
 * @description : 呼叫类型
 * @date: 2020-08-11 17:37
 */
public enum CallTypeEnum implements IEnum<Integer> {
    /**
     * 主叫
     */
    CALL(0, "主叫"),
    /**
     * 被叫
     */
    P_CALL(1, "被叫"),
    ;

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

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

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

    /**
     * 获取值
     *
     * @return 值
     */
    @JsonValue
    @Override
    public Integer getValue() {
        return value;
    }

    /**
     * 获取描述
     *
     * @return 值
     */
    @JsonCreator
    public static String getNameByVale(final Integer value) {
        for (final CallTypeEnum typeEnum : CallTypeEnum.values()) {
            if (typeEnum.value.equals(value)) {
                return typeEnum.getName();
            }
        }
        return "";
    }
}