package com.huatek.busi.common;

import java.util.Objects;

import com.huatek.busi.entity.ArresterReadTable;
import com.huatek.busi.entity.GisReadTable;
import com.huatek.busi.entity.TransformerReadTable;

import lombok.Getter;

/**
 * 104监测类型编码
 * @author edward_luo
 *
 * @Date 2019年8月22日
 */
public enum PointTableMonitorTypeCode {
	
	/** 变压器——图片 */
    BYQ_PICEURE("0211051", TransformerReadTable.class),
    /** 断路器/GIS——图片 */
    GIS_PICEURE("0121051", GisReadTable.class),

    /** 避雷器——图片 */
    BLQ_PICEURE("0441051", ArresterReadTable.class);

    /** 监测类型编码，监测类型的唯一标识 */
    @Getter
    private final String code;

    @Getter
    private final String monitorType;

    @Getter
    private final String dataType;

    @Getter
    private final Class<?> tableClass;

    private PointTableMonitorTypeCode(String code, Class<?> tableClass) {
        this.code = code;
        this.monitorType = code.substring(0, 2);
        this.dataType = code.substring(2, 3);
        this.tableClass = tableClass;
    }

    public static PointTableMonitorTypeCode from(String code) {
        for (PointTableMonitorTypeCode cacMonitorTypeCode : PointTableMonitorTypeCode.values()) {
            if (Objects.equals(code, cacMonitorTypeCode.code)) {
                return cacMonitorTypeCode;
            }
        }
        throw new RuntimeException("监测编码未定义：" + code);
    }

    public boolean isThis(String code) {
        return this.code.equals(code);
    }
}