@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); }
@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); }
/** * 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); }
/** * 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); }