package com.sheep.gamegroup.model.entity;

import java.io.Serializable;

/**
 * Created by ljy on 2018/3/20.
 */

public class RecyleObj  implements Serializable {

    private RecyleType recyleType;

    private int index;

    private Object dataObj;

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }

    public Object getDataObj() {
        return dataObj;
    }

    public <T> T getDataObjT() {
        return (T) dataObj;
    }

    public <T> T getDataObjT(T classz) {
        return (T) dataObj;
    }

    public void setDataObj(Object dataObj) {
        this.dataObj = dataObj;
    }

    public RecyleType getRecyleType() {
        return recyleType;
    }

    public void setRecyleType(RecyleType recyleType) {
        this.recyleType = recyleType;
    }


    /**
     * 生成指定RecyleView的类
     *
     * @param recyleType
     * @param dataObj
     * @return
     */
    public static RecyleObj make(RecyleType recyleType, Object dataObj) {
        RecyleObj recyleObj = new RecyleObj();
        recyleObj.setRecyleType(recyleType);
        recyleObj.setDataObj(dataObj);
        return recyleObj;
    }

    public static RecyleObj make(RecyleType recyleType, Object dataObj, int position) {
        RecyleObj recyleObj = new RecyleObj();
        recyleObj.setRecyleType(recyleType);
        recyleObj.setDataObj(dataObj);
        recyleObj.setIndex(position);
        return recyleObj;
    }

}
