package cn.ibizlab.core.extensions.domain;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.springframework.util.StringUtils;

import java.io.Serializable;

@Data
public class LocalMsgEvent implements Serializable {

    private String body;


    public <T> void setMessage(T message)
    {
        body = JSON.toJSONString(message);
    }

    public <T> T getMessage(Class<T> clazz)
    {
        if(StringUtils.isEmpty(body))
            return null;
        return JSON.parseObject(body,clazz);
    }

    private String tags = "default";

    public int getType()
    {
        return "default".equals(tags)?2:1;
    }
}
