@SuppressWarnings("unchecked") public static void readCollectionFromBundle(Collection collection, Bundle bundle, Class itemClass, String key) { collection.addAll(ArrayListBundler.readArrayListFromBundle(bundle, itemClass, key)); } }
@SuppressWarnings("unchecked") public static void writeCollectionToBundle(Collection collection, Bundle bundle, Class itemClass, String key) { ArrayList arrayList = collection instanceof ArrayList ? (ArrayList) collection : new ArrayList(collection); ArrayListBundler.writeArrayListToBundle(arrayList, bundle, itemClass, key); }
public static <T> ArrayList<T> readArrayListFromBundle(Bundle bundle, Class<T> itemClass, String key) { return getListBundlerForItemClass(itemClass).readFromBundle(bundle, key); }
public static <T> void writeArrayListToBundle(ArrayList<T> list, Bundle bundle, Class<T> itemClass, String key) { getListBundlerForItemClass(itemClass).writeToBundle(list, bundle, key); }
public static <T> void writeArrayListToBundle(ArrayList<T> list, Bundle bundle, Class<T> itemClass, String key) { getListBundlerForItemClass(itemClass).writeToBundle(list, bundle, key); }
@SuppressWarnings("unchecked") public static void readCollectionFromBundle(Collection collection, Bundle bundle, Class itemClass, String key) { collection.addAll(ArrayListBundler.readArrayListFromBundle(bundle, itemClass, key)); } }
@SuppressWarnings("unchecked") public static void writeCollectionToBundle(Collection collection, Bundle bundle, Class itemClass, String key) { ArrayList arrayList = collection instanceof ArrayList ? (ArrayList) collection : new ArrayList(collection); ArrayListBundler.writeArrayListToBundle(arrayList, bundle, itemClass, key); }
public static <T> ArrayList<T> readArrayListFromBundle(Bundle bundle, Class<T> itemClass, String key) { return getListBundlerForItemClass(itemClass).readFromBundle(bundle, key); }
String bundleKey) { ArrayList<K> keys = ArrayListBundler.readArrayListFromBundle(bundle, keyClass, bundleKey + KEYS_SUFFIX); ArrayList<V> values = ArrayListBundler.readArrayListFromBundle(bundle, valueClass, bundleKey + VALUES_SUFFIX);
/** * Write the given map to bundle, using the given {@code bundleKey} to identify it. * * @param map The Map to write. * @param bundle The Bundle to which the Map will be written. * @param keyClass The class representing the type for the map keys. * @param valueClass The class representing the type for the map values. * @param bundleKey The string used to identify the map for later retrieval (see {@link * Bundle#get(String)}). * @param <K> The type for the map keys. * @param <V> The type for the map values. */ public static <K, V> void writeMapToBundle(Map<K, V> map, Bundle bundle, Class<K> keyClass, Class<V> valueClass, String bundleKey) { ArrayList<K> keys = new ArrayList<>(map.size()); ArrayList<V> values = new ArrayList<>(map.size()); for (Map.Entry<K, V> entry : map.entrySet()) { keys.add(entry.getKey()); values.add(entry.getValue()); } ArrayListBundler.writeArrayListToBundle(keys, bundle, keyClass, bundleKey + KEYS_SUFFIX); ArrayListBundler.writeArrayListToBundle(values, bundle, valueClass, bundleKey + VALUES_SUFFIX); }
String bundleKey) { ArrayList<K> keys = ArrayListBundler.readArrayListFromBundle(bundle, keyClass, bundleKey + KEYS_SUFFIX); ArrayList<V> values = ArrayListBundler.readArrayListFromBundle(bundle, valueClass, bundleKey + VALUES_SUFFIX);
/** * Write the given map to bundle, using the given {@code bundleKey} to identify it. * * @param map The Map to write. * @param bundle The Bundle to which the Map will be written. * @param keyClass The class representing the type for the map keys. * @param valueClass The class representing the type for the map values. * @param bundleKey The string used to identify the map for later retrieval (see {@link * Bundle#get(String)}). * @param <K> The type for the map keys. * @param <V> The type for the map values. */ public static <K, V> void writeMapToBundle(Map<K, V> map, Bundle bundle, Class<K> keyClass, Class<V> valueClass, String bundleKey) { ArrayList<K> keys = new ArrayList<>(map.size()); ArrayList<V> values = new ArrayList<>(map.size()); for (Map.Entry<K, V> entry : map.entrySet()) { keys.add(entry.getKey()); values.add(entry.getValue()); } ArrayListBundler.writeArrayListToBundle(keys, bundle, keyClass, bundleKey + KEYS_SUFFIX); ArrayListBundler.writeArrayListToBundle(values, bundle, valueClass, bundleKey + VALUES_SUFFIX); }