package cn.hnthyy.thmz.enums;

import java.util.Arrays;
import java.util.List;

/**
 * yes or no enum
 */
public enum GenderEnum {
    MAN(1,"男"),
    WOMAN(2,"女"),
    UNKNOWN(0,"未知");

    public Integer code;
    public String name;

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

    /**
     * 根据编码查询对应的类型
     * @param code
     * @return
     */
    public static GenderEnum getGenderByCode(Integer code){
        List<GenderEnum> genderEnums= Arrays.asList(values());
        for (GenderEnum genderEnum:genderEnums){
            if(genderEnum.code.equals(code)){
                return genderEnum;
            }
        }
        return null;
    }
}
