package thyyxxk.webserver.constants.sidicts;

import thyyxxk.webserver.utils.StringUtil;

/**
 * @description: 性别
 * @author: DingJie
 * @create: 2021/7/1010:15
 */
public enum Gend {

    UNKNOWN("0", "未知"),

    MALE("1", "男"),

    FEMALE("2", "女"),

    NOT_SPECIFIED("9", "未说明性别");

    private final String code;
    private final String name;

    Gend(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static Gend get(String code) {
        if (StringUtil.isBlank(code)) {
            return NOT_SPECIFIED;
        }
        for (Gend gend : Gend.values()) {
            if (code.trim().equals(gend.getCode())) {
                return gend;
            }
        }
        return UNKNOWN;
    }
}
