MCPcopy Create free account
hub / github.com/antlr/codebuff / copyOf

Method copyOf

corpus/java/training/guava/collect/ImmutableMap.java:318–334  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

316 * @throws NullPointerException if any key or value in {@code map} is null
317 */
318 public static <K, V> ImmutableMap<K, V> copyOf(Map<? extends K, ? extends V> map) {
319 if ((map instanceof ImmutableMap) && !(map instanceof ImmutableSortedMap)) {
320 // TODO(lowasser): Make ImmutableMap.copyOf(immutableBiMap) call copyOf()
321 // on the ImmutableMap delegate(), rather than the bimap itself
322
323 @SuppressWarnings("unchecked") // safe since map is not writable
324 ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) map;
325 if (!kvMap.isPartialView()) {
326 return kvMap;
327 }
328 } else if (map instanceof EnumMap) {
329 @SuppressWarnings("unchecked") // safe since map is not writable
330 ImmutableMap<K, V> kvMap = (ImmutableMap<K, V>) copyOfEnumMap((EnumMap<?, ?>) map);
331 return kvMap;
332 }
333 return copyOf(map.entrySet());
334 }
335
336 /**
337 * Returns an immutable map containing the specified entries. The returned

Callers 12

getAllMethod · 0.95
getAllPresentMethod · 0.95
getAllMethod · 0.95
getAllPresentMethod · 0.95
toMapMethod · 0.95
SparseImmutableTableMethod · 0.95
getClassPathEntriesMethod · 0.95
getTypeMappingsMethod · 0.95
ofImmutableMethod · 0.95
ofImmutableMethod · 0.95
ofImmutableMethod · 0.95
startupTimesMethod · 0.95

Calls 8

copyOfEnumMapMethod · 0.95
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