package com.usky.rule.vo.log;

import com.usky.rule.util.JsonUtil;
import com.usky.rule.vo.log.Content;
import com.usky.rule.vo.log.DeviceTriggerLog;
import java.util.Map;

public class ConstraintDeviceSerialization implements RuleEngineLogSerialization<DeviceTriggerLog> {
    public ConstraintDeviceSerialization() {
    }

    public DeviceTriggerLog serialize(String detail) {
        return (DeviceTriggerLog)JsonUtil.toObject(detail, DeviceTriggerLog.class);
    }

    public Content toContent(Object obj) {
        if (obj instanceof Map) {
            DeviceTriggerLog deviceTriggerLog = (DeviceTriggerLog)JsonUtil.toObject((Map)obj, DeviceTriggerLog.class);
            return TriggerDeviceSerialization.getContent(deviceTriggerLog);
        } else if (obj instanceof DeviceTriggerLog) {
            return TriggerDeviceSerialization.getContent((DeviceTriggerLog)obj);
        } else {
            throw new ClassCastException("ConstraintDeviceSerialization不支持该类型的转换");
        }
    }

    public String getType() {
        return "constraint:device";
    }
}