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.CronTriggerLog;
import java.util.Map;

public class ConstraintCronSerialization implements RuleEngineLogSerialization<CronTriggerLog> {
    public ConstraintCronSerialization() {
    }

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

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

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