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

Method immutableEnumMap

output/java_guava/1.4.16/Maps.java:138–155  ·  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

136 */
137
138 @GwtCompatible(serializable = true)
139 @Beta
140 public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(Map<K, ? extends V> map) {
141 if (map instanceof ImmutableEnumMap) {
142
143 @SuppressWarnings("unchecked") // safe covariant cast
144 ImmutableEnumMap<K, V> result = (ImmutableEnumMap<K, V>) map;
145 return result;
146 } else if (map.isEmpty()) {
147 return ImmutableMap.of();
148 } else {
149 for (Map.Entry<K, ? extends V> entry : map.entrySet()) {
150 checkNotNull(entry.getKey());
151 checkNotNull(entry.getValue());
152 }
153 return ImmutableEnumMap.asImmutable(new EnumMap<K, V>(map));
154 }
155 }
156
157 /**
158 * 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