package com.diagbot.enums.data;

import lombok.Setter;

public enum MarriageEnum implements AKeyedNamed{
    UNMARRIED("1", "未婚"),
    MARRIED("2", "已婚"),
    WIDOWED("3", "丧偶"),
    DIVORCE("4", "离婚"),
    OTHER("9", "其他");

    @Setter
    private String key;

    @Setter
    private String name;

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

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

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

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

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