package com.ycwl.basic.device.checker.helper;

import com.alibaba.fastjson.JSON;
import com.ycwl.basic.model.pc.device.entity.DeviceConfigEntity;
import com.ycwl.basic.model.pc.device.entity.DeviceEntity;
import lombok.Setter;

public abstract class CommonDeviceChecker<C> {
    protected C config;
    @Setter
    protected DeviceEntity device;
    @Setter
    protected DeviceConfigEntity deviceConfig;

    public CommonDeviceChecker(String configJson) {
        config = JSON.parseObject(configJson, getConfigClass());
    }

    @SuppressWarnings("unchecked")
    private Class<C> getConfigClass() {
        return (Class<C>) ((java.lang.reflect.ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
    }
}
