@Test public void testMapConversion() { PersistableBundle bundle = getFilledBundle(10); PersistableBundle convertedBundle = new PersistableBundle(bundle.toMap(10), 10); assertEquals(bundle.toMap(10), convertedBundle.toMap(10)); }
@RestrictTo(RestrictTo.Scope.LIBRARY) public Map<String, ?> toMap(int depth) { if (depth <= 0) { return null; } Map<String, Object> map = new HashMap<>(this.map); for (String key : map.keySet()) { Object object = map.get(key); if (object instanceof PersistableBundle) { map.put(key, ((PersistableBundle) object).toMap(depth - 1)); } } return map; }
PersistableBundle implements Parcelable { @RestrictTo(RestrictTo.Scope.LIBRARY) public Map<String, ?> toMap(int depth) { if (depth <= 0) { return null; } Map<String, Object> map = new HashMap<>(this.map); for (String key : map.keySet()) { Object object = map.get(key); if (object instanceof PersistableBundle) { map.put(key, ((PersistableBundle) object).toMap(depth - 1)); } } return map; } }
PersistableBundle implements Parcelable { @RestrictTo(RestrictTo.Scope.LIBRARY) public Map<String, ?> toMap(int depth) { if (depth <= 0) { return null; } Map<String, Object> map = new HashMap<>(this.map); for (String key : map.keySet()) { Object object = map.get(key); if (object instanceof PersistableBundle) { map.put(key, ((PersistableBundle) object).toMap(depth - 1)); } } return map; } PersistableBundle();  PersistableBundle(PersistableBundle bundle);  PersistableBundle(Bundle bundle); @TargetApi(Build.VERSION_CODES.LOLLIPOP) @RestrictTo(RestrictTo.Scope.LIBRARY)  PersistableBundle(android.os.PersistableBundle bundle); @RestrictTo(RestrictTo.Scope.LIBRARY) @SuppressWarnings("unchecked")  PersistableBundle(Map<String, ?> map, int depth); @SuppressWarnings("unchecked")  PersistableBundle(Parcel in); }
PersistableBundle implements Parcelable { @RestrictTo(RestrictTo.Scope.LIBRARY) public Map<String, ?> toMap(int depth) { if (depth <= 0) { return null; } Map<String, Object> map = new HashMap<>(this.map); for (String key : map.keySet()) { Object object = map.get(key); if (object instanceof PersistableBundle) { map.put(key, ((PersistableBundle) object).toMap(depth - 1)); } } return map; } PersistableBundle();  PersistableBundle(PersistableBundle bundle);  PersistableBundle(Bundle bundle); @TargetApi(Build.VERSION_CODES.LOLLIPOP) @RestrictTo(RestrictTo.Scope.LIBRARY)  PersistableBundle(android.os.PersistableBundle bundle); @RestrictTo(RestrictTo.Scope.LIBRARY) @SuppressWarnings("unchecked")  PersistableBundle(Map<String, ?> map, int depth); @SuppressWarnings("unchecked")  PersistableBundle(Parcel in); boolean containsKey(String key); boolean isEmpty(); int size(); Object get(String key); String getString(String key, String defaultValue); String getString(String key); int getInt(String key, int defaultValue); int getInt(String key); long getLong(String key, long defaultValue); long getLong(String key); double getDouble(String key, double defaultValue); double getDouble(String key); boolean getBoolean(String key); boolean getBoolean(String key, boolean defaultValue); String[] getStringArray(String key); int[] getIntArray(String key); long[] getLongArray(String key); double[] getDoubleArray(String key); boolean[] getBooleanArray(String key); PersistableBundle getPersistableBundleCompat(String key); void putString(String key, String value); void putInt(String key, int value); void putLong(String key, long value); void putDouble(String key, double value); void putBoolean(String key, boolean value); void putStringArray(String key, String[] value); void putIntArray(String key, int[] value); void putLongArray(String key, long[] value); void putDoubleArray(String key, double[] value); void putBooleanArray(String key, boolean[] value); void putPersistableBundleCompat(String key, PersistableBundle value); void putAll(PersistableBundle bundle); void remove(String key); void clear(); @NonNull Bundle toBundle(); @NonNull @TargetApi(Build.VERSION_CODES.LOLLIPOP) @RestrictTo(RestrictTo.Scope.LIBRARY) android.os.PersistableBundle toPersistableBundle(); @RestrictTo(RestrictTo.Scope.LIBRARY) Map<String, ?> toMap(int depth); @Override void writeToParcel(Parcel dest, int flags); @Override int describeContents(); }
PersistableBundle implements Parcelable { @RestrictTo(RestrictTo.Scope.LIBRARY) public Map<String, ?> toMap(int depth) { if (depth <= 0) { return null; } Map<String, Object> map = new HashMap<>(this.map); for (String key : map.keySet()) { Object object = map.get(key); if (object instanceof PersistableBundle) { map.put(key, ((PersistableBundle) object).toMap(depth - 1)); } } return map; } PersistableBundle();  PersistableBundle(PersistableBundle bundle);  PersistableBundle(Bundle bundle); @TargetApi(Build.VERSION_CODES.LOLLIPOP) @RestrictTo(RestrictTo.Scope.LIBRARY)  PersistableBundle(android.os.PersistableBundle bundle); @RestrictTo(RestrictTo.Scope.LIBRARY) @SuppressWarnings("unchecked")  PersistableBundle(Map<String, ?> map, int depth); @SuppressWarnings("unchecked")  PersistableBundle(Parcel in); boolean containsKey(String key); boolean isEmpty(); int size(); Object get(String key); String getString(String key, String defaultValue); String getString(String key); int getInt(String key, int defaultValue); int getInt(String key); long getLong(String key, long defaultValue); long getLong(String key); double getDouble(String key, double defaultValue); double getDouble(String key); boolean getBoolean(String key); boolean getBoolean(String key, boolean defaultValue); String[] getStringArray(String key); int[] getIntArray(String key); long[] getLongArray(String key); double[] getDoubleArray(String key); boolean[] getBooleanArray(String key); PersistableBundle getPersistableBundleCompat(String key); void putString(String key, String value); void putInt(String key, int value); void putLong(String key, long value); void putDouble(String key, double value); void putBoolean(String key, boolean value); void putStringArray(String key, String[] value); void putIntArray(String key, int[] value); void putLongArray(String key, long[] value); void putDoubleArray(String key, double[] value); void putBooleanArray(String key, boolean[] value); void putPersistableBundleCompat(String key, PersistableBundle value); void putAll(PersistableBundle bundle); void remove(String key); void clear(); @NonNull Bundle toBundle(); @NonNull @TargetApi(Build.VERSION_CODES.LOLLIPOP) @RestrictTo(RestrictTo.Scope.LIBRARY) android.os.PersistableBundle toPersistableBundle(); @RestrictTo(RestrictTo.Scope.LIBRARY) Map<String, ?> toMap(int depth); @Override void writeToParcel(Parcel dest, int flags); @Override int describeContents(); static final PersistableBundle EMPTY; static final Parcelable.Creator<PersistableBundle> CREATOR; }