Returns an immutable map containing the same entries as map. If map somehow contains entries with duplicate keys (for example, if it is a SortedMap whose comparator is not consistent with equals ), the results of this method are undefined. Despite the method name, t
(Map<? extends K, ? extends V> map)
| 335 | |
| 336 | |
| 337 | public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) { |
| 338 | if ((map instanceof ImmutableMap) && !(map instanceof ImmutableSortedMap)) { |
| 339 | // TODO(lowasser): Make ImmutableMap.copyOf(immutableBiMap) call copyOf() |
| 340 | // on the ImmutableMap delegate(), rather than the bimap itself |
| 341 | |
| 342 | @SuppressWarnings("unchecked") // safe since map is not writable |
| 343 | ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) map; |
| 344 | if (!kvMap.isPartialView()) { |
| 345 | return kvMap; |
| 346 | } |
| 347 | } else if (map instanceof EnumMap) { |
| 348 | |
| 349 | @SuppressWarnings("unchecked") // safe since map is not writable |
| 350 | ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) copyOfEnumMap((EnumMap<?, ?>) map); |
| 351 | return kvMap; |
| 352 | } |
| 353 | return copyOf(map.entrySet()); |
| 354 | } |
| 355 | |
| 356 | /** |
| 357 | * Returns an immutable map containing the specified entries. The returned |
no test coverage detected