package com.lantone.security.enums;

import lombok.Getter;
import lombok.Setter;

/**
 * @Description: 是否，例如：是否关联
 * @author: gaodm
 * @time: 2018/9/3 16:01
 */
public enum RelationEnum {

    Y("Y", "1"),
    N("N", "0");

    @Getter
    @Setter
    private String key;

    @Getter
    @Setter
    private String name;

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

    public static RelationEnum getEnum(String key) {
        for (RelationEnum item : RelationEnum.values()) {
            if (item.key.equals(key)) {
                return item;
            }
        }
        return null;
    }

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