package com.phlx.wool.event;

import android.os.Parcel;
import android.os.Parcelable;

/**
 * <pre>
 *     author : lei
 *     e-mail : 18600395998@163.com
 *     time   : 2019/06/10
 *     desc   : RxBus数据模型类
 *     version: 1.0
 * </pre>
 */
public class EventMsg<T> implements Parcelable {

    private String action;
    private T obj;

    public EventMsg() {
    }

    public EventMsg(String action, T obj) {
        this.action = action;
        this.obj = obj;
    }

    protected EventMsg(Parcel in) {
        action = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(action);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<EventMsg> CREATOR = new Creator<EventMsg>() {
        @Override
        public EventMsg createFromParcel(Parcel in) {
            return new EventMsg(in);
        }

        @Override
        public EventMsg[] newArray(int size) {
            return new EventMsg[size];
        }
    };

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    public T getObj() {
        return obj;
    }

    public void setObj(T obj) {
        this.obj = obj;
    }

    @Override
    public String toString() {
        return "EventMsg{" +
                "action='" + action + '\'' +
                ", obj=" + obj +
                '}';
    }
}
