MCPcopy
hub / github.com/google/guava / copyOf

Method copyOf

guava/src/com/google/common/collect/ImmutableBiMap.java:534–545  ·  view source on GitHub ↗

Returns an immutable bimap containing the same entries as {@code map}. If {@code map} somehow contains entries with duplicate keys (for example, if it is a {@code SortedMap} whose comparator is not <i>consistent with equals</i>), the results of this method are undefined. <p>The returned {@code BiMa

(Map<? extends K, ? extends V> map)

Source from the content-addressed store, hash-verified

532 * @throws NullPointerException if any key or value in {@code map} is null
533 */
534 public static <K, V> ImmutableBiMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
535 if (map instanceof ImmutableBiMap) {
536 @SuppressWarnings("unchecked") // safe since map is not writable
537 ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map;
538 // TODO(lowasser): if we need to make a copy of a BiMap because the
539 // forward map is a view, don't make a copy of the non-view delegate map
540 if (!bimap.isPartialView()) {
541 return bimap;
542 }
543 }
544 return copyOf(map.entrySet());
545 }
546
547 /**
548 * Returns an immutable bimap containing the given entries. The returned bimap iterates over

Callers 3

ofImmutableMethod · 0.95
ofImmutableMethod · 0.95
buildOrThrowMethod · 0.45

Calls 7

toArrayMethod · 0.95
ofMethod · 0.95
fromEntriesMethod · 0.95
entrySetMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
isPartialViewMethod · 0.45

Tested by

no test coverage detected