code: public static <K, V> Map<K, V> toImmutableMap(final Map<K, V> map) {
      switch (map.size()) {
        case 0:
          return Collections.emptyMap();
        case 1:
          final Entry<K, V> entry = map.entrySet().iterator().next();
          return Collections.singletonMap(entry.getKey(), entry.getValue());
        default:
          return Collections.unmodifiableMap(map);
      }
    }
docs: list to imuteable map.
  
  @param map map to convert
  @return imuteable map