package com.diagbot.enums;

import com.diagbot.core.KeyedNamed;
import lombok.Setter;

/**
 * @Description: 不通过原因枚举类型
 * @author: wangyu
 * @time: 11:06 2018/9/27
 */
public enum NotPassEnum implements KeyedNamed {
    ImperfectInformation(1, "产品即将升级"),
    AgencyError(2, "付款异常"),
    CancellationOfOrder(3,"取消购买");

    @Setter
    private Integer key;

    @Setter
    private String name;

    NotPassEnum(Integer key, String name) {
        this.key = key;
        this.name = name;
    }

    public static NotPassEnum getEnum(Integer key) {
        for (NotPassEnum item : NotPassEnum.values()) {
            if (item.key == key) {
                return item;
            }
        }
        return null;
    }

    public static String getName(Integer key) {
        NotPassEnum item = getEnum(key);
        return item != null ? item.name : null;
    }

    @Override
    public int getKey() {
        return key;
    }

    @Override
    public String getName() {
        return name;
    }
}

