package com.mosty.base.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;

/**
 * 布控数据库类型
 */
@Getter
public enum BKDbTypeEnum implements Serializable {
    All("所有","All",false),        //所有默认
    Personnel("人员","Personnel",false),  //人员
    Car("车辆","Car",true);         //车辆

    private String name;
    private String code;
    private boolean hidden;

    private BKDbTypeEnum(String name, String code, boolean hidden){
        this.name = name;
        this.code = code;
        this.hidden = hidden;

    }

    /**
     * 根据代码转换成枚举类型
     * @param value
     * @return
     */
    public  static BKDbTypeEnum toCode(String value){
        if(StringUtils.isEmpty(value)){
            return  null;
        }
        for (BKDbTypeEnum _tmp : BKDbTypeEnum.values()){
            if(_tmp.getCode().toLowerCase().equals(value.toLowerCase())){
                return  _tmp;
            }
        }
        return  null;
    }
}
