package cgmblelib.Enum;

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

/**
 * UUID枚举
 * @author minyuchun
 */
public enum enumUUID{
    /**
     * 已经完成的
     */
    complete(
            "CGM",
            new String[]{"SN06","SN08","SN10","SN12"},
            "0000fff0-0000-1000-8000-00805f9b34fb",
            "0000fff2-0000-1000-8000-00805f9b34fb",
            "0000fff1-0000-1000-8000-00805f9b34fb"
    ),

    /**
     * 2020年2月8日之后正在进行测试
     */
    test(
            "CGM",
            new String[]{"SN16"},
            "00001000-1212-efde-1523-785feabcd123",
            "00001001-1212-efde-1523-785feabcd123",
            "00001002-1212-efde-1523-785feabcd123"
    ),
    ;

    private String category;

    private String[] name;

    private String SERVICE;

    private String CHARACTERISTIC_NOTIFICATION;

    private String CHARACTERISTIC_WRITE;

    enumUUID(String category, String[] name, String SERVICE, String CHARACTERISTIC_NOTIFICATION, String CHARACTERISTIC_WRITE) {
        this.category = category;
        this.name = name;
        this.SERVICE = SERVICE;
        this.CHARACTERISTIC_NOTIFICATION = CHARACTERISTIC_NOTIFICATION;
        this.CHARACTERISTIC_WRITE = CHARACTERISTIC_WRITE;
    }

    enumUUID(String[] name, String SERVICE, String CHARACTERISTIC_NOTIFICATION, String CHARACTERISTIC_WRITE) {
        this.name = name;
        this.SERVICE = SERVICE;
        this.CHARACTERISTIC_NOTIFICATION = CHARACTERISTIC_NOTIFICATION;
        this.CHARACTERISTIC_WRITE = CHARACTERISTIC_WRITE;
    }

    public String getCategory() {
        return category;
    }

    public void setCategory(String category) {
        this.category = category;
    }

    public List<String> getName() {
        return Arrays.asList(name);
    }

    public void setName(String[] name) {
        this.name = name;
    }

    public String getSERVICE() {
        return SERVICE;
    }

    public void setSERVICE(String SERVICE) {
        this.SERVICE = SERVICE;
    }

    public String getCHARACTERISTIC_NOTIFICATION() {
        return CHARACTERISTIC_NOTIFICATION;
    }

    public void setCHARACTERISTIC_NOTIFICATION(String CHARACTERISTIC_NOTIFICATION) {
        this.CHARACTERISTIC_NOTIFICATION = CHARACTERISTIC_NOTIFICATION;
    }

    public String getCHARACTERISTIC_WRITE() {
        return CHARACTERISTIC_WRITE;
    }

    public void setCHARACTERISTIC_WRITE(String CHARACTERISTIC_WRITE) {
        this.CHARACTERISTIC_WRITE = CHARACTERISTIC_WRITE;
    }

    public static enumUUID getEnumUUID(String deviceName){
        if (deviceName != null && deviceName.trim().length() >= 4){
            deviceName = deviceName.trim().substring(0,4);
            for (enumUUID e : enumUUID.values()) {
                if (e.getName().contains(deviceName)){
                    return e;
                }
            }
        }
        return test;
    }

    public static enumUUID getEnumUUIDByServiceUUID(String serviceUUID){
        if (serviceUUID != null){
            serviceUUID = serviceUUID.trim();
            for (enumUUID e : enumUUID.values()) {
                if (e.getSERVICE().contains(serviceUUID)){
                    return e;
                }
            }
        }
        return test;
    }

    public static enumUUID getEnumUUIDByCategory(String category){
        if (category != null){
            category = category.trim();
            for (enumUUID e : enumUUID.values()) {
                if (e.getCategory().contains(category)){
                    return e;
                }
            }
        }
        return test;
    }
}
