package com.diagbot.enums;

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

/**
 * @Description:
 * @author: wangyu
 * @time: 11:06 2018/9/27
 */
public enum PaymentMethodEnum implements KeyedNamed {
    PAY(1,"已付费"),
    NOT_PAY(0, "未付费");

    @Setter
    private Integer key;

    @Setter
    private String name;

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

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

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

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

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

