package com.sonic.cow.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 性别
 */
public enum SexEnums {

    MALE(0, "Male"),
    FEMALE(1, "Female"),
    NON(2, "Nonconforming");

    private Integer index;

    private String desc;

    SexEnums(Integer index, String desc) {
        this.index = index;
        this.desc = desc;
    }

    public Integer getIndex() {
        return index;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 性别转换
     * @param index
     * @return
     */
    public static String getSex(String index) {
        if(StringUtils.isEmpty(index)) {
            return "Nonconforming";
        }
        for (SexEnums sexEnums : SexEnums.values()) {
            if(Integer.valueOf(index).equals(sexEnums.getIndex())) {
                return sexEnums.getDesc();
            }
        }
        return "Nonconforming";
    }
}
