package com.ycgis.macall.personalcenter.m.adapterbean;

import android.content.Intent;
import android.os.Bundle;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * created by:   Macall
 * create time:  2023/5/31 10:50
 * copyright:    @ruansee.com
 * Describe:
 */
public class ActionBean extends BaseBean{
    private int iconId;
    private String name;
    private int count;

    private Class aClass;

    private Map<String,Object> param;

    public void addParam(String key,Object value){
        if (param == null)param = new HashMap<>();
        param.put(key,value);
    }

    public Map<String, Object> getParam() {
        return param;
    }

    public int getIconId() {
        return iconId;
    }

    public void setIconId(int iconId) {
        this.iconId = iconId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public Class getaClass() {
        return aClass;
    }

    public void setaClass(Class aClass) {
        this.aClass = aClass;
    }

    /**
     * 设置跳转参数
     * @param intent intent 意向
     * @return intent 意向
     */
    public Intent setIntentParam(Intent intent){
        if (param!=null&&!param.isEmpty()){
            Set<String> strings = param.keySet();
            for (String key :strings) {
                Object o = param.get(key);
                if (o instanceof Integer) {
                    intent.putExtra(key, (int) o);
                } else if (o instanceof String) {
                    intent.putExtra(key, o.toString());
                } else if (o instanceof Boolean) {
                    intent.putExtra(key, (boolean) o);
                } else if (o instanceof Long) {
                    intent.putExtra(key, (long) o);
                } else if (o instanceof Bundle) {
                    intent.putExtra(key, (Bundle) o);
                } else if (o instanceof Byte) {
                    intent.putExtra(key, (byte) o);
                }else if (o instanceof byte[]) {
                    intent.putExtra(key, (byte[]) o);
                }else if (o instanceof Short) {
                    intent.putExtra(key, (short) o);
                }else if (o instanceof Character) {
                    intent.putExtra(key, (char) o);
                }else if (o instanceof String[]) {
                    intent.putExtra(key, (String[]) o);
                }else  if (o instanceof Serializable) {
                    intent.putExtra(key, (Serializable) o);
                }
            }
        }
        return intent;
    }
}
