content: /*
   *  Copyright (C) 2017-present Albie Liang. All rights reserved.
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  
  package cc.suitalk.ipcinvoker.extension;
  
  import android.os.Bundle;
  import android.os.Parcelable;
  
  /**
   * Created by albieliang on 2017/10/27.
   */
  
  public class ParameterHelper {
  
      public static void put(Bundle bundle, String key, Object value) {
          if (value instanceof Integer) {
              bundle.putInt(key, (Integer) value);
          } else if (value instanceof Float) {
              bundle.putFloat(key, (Float) value);
          } else if (value instanceof Character) {
              bundle.putChar(key, (Character) value);
          } else if (value instanceof CharSequence) {
              bundle.putCharSequence(key, (CharSequence) value);
          } else if (value instanceof Long) {
              bundle.putLong(key, (Long) value);
          } else if (value instanceof Short) {
              bundle.putShort(key, (Short) value);
          } else if (value instanceof Byte) {
              bundle.putByte(key, (Byte) value);
          } else if (value instanceof Boolean) {
              bundle.putBoolean(key, (Boolean) value);
          } else if (value instanceof Double) {
              bundle.putDouble(key, (Double) value);
          } else if (value instanceof Parcelable) {
              bundle.putParcelable(key, (Parcelable) value);
          } else if (value instanceof Bundle) {
              bundle.putBundle(key, (Bundle) value);
          } else if (value instanceof int[]) {
              bundle.putIntArray(key, (int[]) value);
          } else if (value instanceof byte[]) {
              bundle.putByteArray(key, (byte[]) value);
          } else if (value instanceof float[]) {
              bundle.putFloatArray(key, (float[]) value);
          } else if (value instanceof double[]) {
              bundle.putDoubleArray(key, (double[]) value);
          } else if (value instanceof boolean[]) {
              bundle.putBooleanArray(key, (boolean[]) value);
          } else if (value instanceof long[]) {
              bundle.putLongArray(key, (long[]) value);
          } else if (value instanceof Parcelable[]) {
              bundle.putParcelableArray(key, (Parcelable[]) value);
          } else if (value instanceof short[]) {
              bundle.putShortArray(key, (short[]) value);
          } else if (value instanceof String[]) {
              bundle.putStringArray(key, (String[]) value);
          } else {
  //            bundle.putString(key, String.valueOf(value));
          }
      }
  
      public static <T> T get(Bundle bundle, String key) {
          return (T) bundle.get(key);
      }
  }
  