docs: @GwtCompatible(serializable = true)
    @Beta
    public static <K extends Enum<K>, V> ImmutableMap<K, V> immutableEnumMap(
        Map<K, ? extends V> map) {
      if (map instanceof ImmutableEnumMap) {
        @SuppressWarnings("unchecked") // safe covariant cast
        ImmutableEnumMap<K, V> result = (ImmutableEnumMap<K, V>) map;
        return result;
      } else if (map.isEmpty()) {
        return ImmutableMap.of();
      } else {
        for (Map.Entry<K, ? extends V> entry : map.entrySet()) {
          checkNotNull(entry.getKey());
          checkNotNull(entry.getValue());
        }
        return ImmutableEnumMap.asImmutable(new EnumMap<K, V>(map));
      }
    }