package cn.hnthyy.thmz.enums;

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

/**
 * yes or no enum
 */
public enum YesNoEnum {
    YES(1,"是"),
    NO(0,"否");

    public Integer code;
    public String name;

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

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