package cgmblelib.Enum;

/**
 * Created by minyuchun on 2019/1/25.
 * @author minyuchun
 * 发射器类型
 */
public enum enumDevice {
    DEVICETEST("SN96",true,false),
    ;
    /**发射器名称开始识别*/
    private String nameStar;
    /**是否需要扫码*/
    private boolean ableScanQRCode;
    /**是否需要扫码 可以忽略*/
    private boolean ableScanQRCodeIgnore;

    enumDevice(String nameStar, boolean ableScanQRCode, boolean ableScanQRCodeIgnore) {
        this.nameStar = nameStar;
        this.ableScanQRCode = ableScanQRCode;
        this.ableScanQRCodeIgnore = ableScanQRCodeIgnore;
    }

    public boolean isAbleScanQRCode() {
        return ableScanQRCode;
    }

    public static enumDevice getEnumDevice(String deviceName){
        if (deviceName != null){
            deviceName = deviceName.trim();
            for (enumDevice e : enumDevice.values()) {
                if (deviceName.startsWith(e.nameStar)){
                    return e;
                }
            }
        }
        return DEVICETEST;
    }

    @Override
    public String toString() {
        return "enumDevice{" +
                "nameStar='" + nameStar + '\'' +
                ", ableScanQRCode=" + ableScanQRCode +
                ", ableScanQRCodeIgnore=" + ableScanQRCodeIgnore +
                '}';
    }
}
