package com.ysnows.base.utils;

import android.os.Bundle;
import android.os.Parcelable;

import androidx.annotation.Nullable;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * 对Bundle进行响应式的封装
 * Created by xianguangjin on 15/12/23.
 */
public class B {

    private static B b;
    private Bundle bundle;

    public static B with() {
        b = new B();
        return b;
    }

    public B() {
        this.bundle = new Bundle();
    }

    public B putString(String name, String value) {
        this.bundle.putString(name, value);
        return this;
    }

    public B putStringArray(String name, String[] value) {
        this.bundle.putStringArray(name, value);
        return this;
    }
    public B putStringArrayList(@Nullable String key, @Nullable ArrayList<String> value) {
        this.bundle.putStringArrayList(key, value);
        return this;
    }

    public B putInt(String name, int value) {
        this.bundle.putInt(name, value);
        return this;
    }

    public B putBoolean(String name, boolean value) {
        this.bundle.putBoolean(name, value);
        return this;
    }

    public B putSR(String name, Serializable value) {
        this.bundle.putSerializable(name, value);
        return this;
    }

    public B putP(String name, Parcelable value) {
        this.bundle.putParcelable(name, value);
        return this;
    }

    public B putPARR(String name, ArrayList<? extends Parcelable> value) {
        this.bundle.putParcelableArrayList(name, value);
        return this;
    }

    public B PutSARR(String name, ArrayList<Serializable> value) {
        this.bundle.putSerializable(name, value);
        return this;
    }

    /**
     * @return 操作完成
     */
    public Bundle ok() {
        return this.bundle;
    }

}
