Returns an immutable bimap 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,
(Map<? extends K, ? extends V> map)
| 271 | |
| 272 | |
| 273 | public static <K, V> ImmutableBiMap<K, V> copyOf(Map<? extends K, ? extends V> map) { |
| 274 | if (map instanceof ImmutableBiMap) { |
| 275 | @SuppressWarnings("unchecked") // safe since map is not writable |
| 276 | ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map; |
| 277 | // TODO(lowasser): if we need to make a copy of a BiMap because the |
| 278 | // forward map is a view, don't make a copy of the non-view delegate map |
| 279 | if (!bimap.isPartialView()) { |
| 280 | return bimap; |
| 281 | } |
| 282 | } |
| 283 | return copyOf(map.entrySet()); |
| 284 | } |
| 285 | |
| 286 | /** |
| 287 | * Returns an immutable bimap containing the given entries. |
no test coverage detected