package com.diagbot.enums.data;

import lombok.Setter;

public enum SexEnum implements AKeyedNamed {
    NUM_MALE("1", "男"),
    NUM_FEMALE("2", "女");

    @Setter
    private String key;

    @Setter
    private String name;

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

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

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

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

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