package com.cisdi.data.DHV.gateway.vo.dhv;

public enum AllowMeasuringPoint {
    //1#XB-10V -02,符合规则的测点
    RegularExpression1("^([\\s]*)([0-9]+)[#]([A-Z]+)([\\s]*)[-]([\\s]*)([0-9]+)([A-Z]+)([\\s]*)([\\s]*)[-]([\\s]*)([0-9]+)([\\s]*)$"),
    //1#XB-ZG1 -05,符合规则的测点
    RegularExpression2("^([\\s]*)([0-9]+)[#]([A-Z]+)([\\s]*)[-]([\\s]*)([A-Z]+)([0-9]+)([\\s]*)([\\s]*)[-]([\\s]*)([0-9]+)([\\s]*)$"),
    //2#XB-1#GF-05,符合规则的测点
    RegularExpression3("^([\\s]*)([0-9]+)[#]([A-Z]+)([\\s]*)[-]([\\s]*)([0-9]+)[#]([A-Z]+)([\\s]*)([\\s]*)[-]([\\s]*)([0-9]+)([\\s]*)$");

    private String reg;

    AllowMeasuringPoint(String reg) {
        this.reg = reg;
    }

    private String getReg() {
        return this.reg;
    }

    public static boolean allowMeasuringPoint(String mp) {
        if (mp == null) {
            return true;
        }
        AllowMeasuringPoint[] allowMeasuringPoints = AllowMeasuringPoint.values();
        for (int i = 0; i < allowMeasuringPoints.length; i++) {
            if (mp.matches(allowMeasuringPoints[i].getReg())) {
                return true;
            }
        }
        return false;
    }
}
