package com.ywt.outpatient.taihe.rpc.domain.enums;

/**
 * 性别枚举
 *
 * @author johnson lin
 * @date 2019/4/30 11:58 AM
 */
public enum Gender {
    /**
     * 未知
     */
    UNKNOWN("未知", 0),
    /**
     * 男
     */
    MALE("男", 1),
    /**
     * 女
     */
    FEMALE("女", 2),
    /**
     * 未说明
     */
    UNSPECIFIED("未说明", 9);

    private final String displayName;

    private final int value;

    Gender(String displayName, int value) {
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static Gender valueOf(int value) {
        for (Gender sex : Gender.values()) {
            if (sex.getValue() == value) {
                return sex;
            }
        }
        return null;
    }

    public static String getDisplayName(int value) {
        Gender sex = valueOf(value);
        return sex != null ? sex.getDisplayName() : UNKNOWN.getDisplayName();
    }
}
