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

Method immutableEnumMap

corpus/java/training/guava/collect/Maps.java:134–151  ·  view source on GitHub ↗

Returns an immutable map instance containing the given entries. Internally, the returned map will be backed by an EnumMap. The iteration order of the returned map follows the enum's iteration order, not the order in which the elements appear in the given map. @param map the map to make

(
      Map<K, ? extends V> map)

Source from the content-addressed store, hash-verified

132 * @since 14.0
133 */
134 @GwtCompatible(serializable = true)
135 @Beta
136 public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(
137 Map<K, ? extends V> map) {
138 if (map instanceof ImmutableEnumMap) {
139 @SuppressWarnings("unchecked") // safe covariant cast
140 ImmutableEnumMap<K, V> result = (ImmutableEnumMap<K, V>) map;
141 return result;
142 } else if (map.isEmpty()) {
143 return ImmutableMap.of();
144 } else {
145 for (Map.Entry<K, ? extends V> entry : map.entrySet()) {
146 checkNotNull(entry.getKey());
147 checkNotNull(entry.getValue());
148 }
149 return ImmutableEnumMap.asImmutable(new EnumMap<K, V>(map));
150 }
151 }
152
153 /**
154 * Creates a <i>mutable</i>, empty {@code HashMap} instance.

Callers

nothing calls this directly

Calls 7

ofMethod · 0.95
asImmutableMethod · 0.95
isEmptyMethod · 0.65
entrySetMethod · 0.65
getKeyMethod · 0.65
getValueMethod · 0.65
checkNotNullMethod · 0.45

Tested by

no test coverage detected