public static <V> CharArrayMap<V> unmodifiableMap(CharArrayMap<V> map) {
    if (map == null)
      throw new NullPointerException("Given map is null");
    if (map == emptyMap() || map.isEmpty())
      return emptyMap();
    if (map instanceof UnmodifiableCharArrayMap)
      return map;
    return new UnmodifiableCharArrayMap<>(map);
  }
Returns an unmodifiable {@link CharArrayMap}. This allows to provide
unmodifiable views of internal map for "read-only" use.

@param map
         a map for which the unmodifiable map is returned.
@return an new unmodifiable {@link CharArrayMap}.
@throws NullPointerException
          if the given map is <code>null</code>.
linguistics/src/main/java/com/yahoo/language/simple/kstem/CharArrayMap.java