Creates an immutable copy of the specified map.

@param map the map to copy from
@return an immutable map copy
176018
public static <K, V> Map<K, V> immutableMapCopy(Map<K, V> map) {
      if (map == null) return null;
      if (map.isEmpty()) return Collections.emptyMap();
      if (map.size() == 1) {
         Map.Entry<K, V> me = map.entrySet().iterator().next();
         return Collections.singletonMap(me.getKey(), me.getValue());
      }

      Map<? extends K, ? extends V> copy = ObjectDuplicator.duplicateMap(map);

      if (copy == null)
         copy = attemptCopyConstructor(map, Map.class);
      if (copy == null)
         copy = new HashMap<>(map);

      return new ImmutableMapWrapper<>(copy);
   }
1128956
public static Map<String, Tag<?>> cloneMap(Map<String, Tag<?>> map) {
        if (map == null) {
            return null;
        }

        Map<String, Tag<?>> newMap = new HashMap<String, Tag<?>>();
        for (Entry<String, Tag<?>> entry : map.entrySet()) {
            newMap.put(entry.getKey(), entry.getValue().clone());
        }
        return newMap;
    }
735015
public void putMap(Map<String, String> map)
    {
        if (map == null) {
            putNumber1(0);
        }
        else {
            Utils.checkArgument(map.size() < 256, "Map has to be smaller than 256 elements");
            putNumber1(map.size());
            for (Entry<String, String> entry : map.entrySet()) {
                if (entry.getKey().contains("=")) {
                    throw new IllegalArgumentException("Keys cannot contain '=' sign. " + entry);
                }
                if (entry.getValue().contains("=")) {
                    throw new IllegalArgumentException("Values cannot contain '=' sign. " + entry);
                }
                String val = entry.getKey() + "=" + entry.getValue();
                putString(val);
            }
        }
    }
91886
public static <K, V> Map<K, V> newHashMap(Map<? extends K, ? extends V> m) {
    return new HashMap<K, V>(m);
  }
971620
public static <K, V> Map<K, V> cast(Map<?, ?> map) {
    return map == null ? null : new CastingMap<K, V>(map);
  }
127692
@NonNull
  public static <K, V> Map<K, V> immutableCopyOf(@NonNull Map<K, V> map) {
    return Collections.unmodifiableMap(new LinkedHashMap<>(map));
  }
1063067
public JsonWriter value(Map<String, ?> map) throws IOException {
      if (map == null) {
         nullValue();
      } else {
         boolean inObject = inObject();
         if (!inObject) beginObject();
         for (Map.Entry<String, ?> entry : map.entrySet()) {
            property(entry.getKey(), entry.getValue());
         }
         if (!inObject) endObject();
      }
      popIf(JsonTokenType.NAME);
      return this;
   }
1039212
public static <K, KK, VV> Map<KK, VV> getAndPutMapIfAbsent(final Map<K, Map<KK, VV>> map, final K key) {
        Map<KK, VV> v = map.get(key);

        if (v == null) {
            v = new HashMap<>();
            v = map.put(key, v);
        }

        return v;
    }
347788
public static Map<String, Object> newFlatKeyMap(Map<String, ?> map) {
        return newFlatKeyMap(new HashMap<>(), map);
    }
1001153
public static VariableMap fromMap(Map<String, Object> map) {
    if(map instanceof VariableMap) {
      return (VariableMap) map;
    }
    else {
      return new VariableMapImpl(map);
    }
  }
103081
public static <K, V> Map.Entry<K, V> immutableEntry(Map.Entry<K, V> entry) {
      return new ImmutableEntry<>(entry);
   }
1266754
public V get(Map<?, V> map){
		for (Object k : keys){
			V v = map.get(k);
			if (v != null){
				return v;
			}
		}
		return null;
	}
1290336
private static <K, V> void makeSetsImmutable(Map<K, Set<V>> map) {
    Set<K> keys = map.keySet();
    for (K key : keys) {
      Set<V> value = map.get(key);
      map.put(key, Collections.unmodifiableSet(value));
    }
  }
181837
public static <T> Collection<T> immutableCollectionCopy(Collection<T> collection) {
      if (collection == null) return null;
      if (collection.isEmpty()) return Collections.emptySet();
      if (collection.size() == 1) return Collections.singleton(collection.iterator().next());

      Collection<? extends T> copy = ObjectDuplicator.duplicateCollection(collection);
      if (copy == null)
         copy = attemptCopyConstructor(collection, Collection.class);
      if (copy == null)
         copy = new ArrayList<>(collection);

      return new ImmutableCollectionWrapper<>(copy);
   }
668331
public static <K,V> MultiValueMap<K,V> unmodifiableMultiValueMap(MultiValueMap<? extends K, ? extends V> map) {
		Assert.notNull(map, "'map' must not be null");
		Map<K, List<V>> result = new LinkedHashMap<K, List<V>>(map.size());
		for (Map.Entry<? extends K, ? extends List<? extends V>> entry : map.entrySet()) {
			List<V> values = Collections.unmodifiableList(entry.getValue());
			result.put(entry.getKey(), values);
		}
		Map<K, List<V>> unmodifiableMap = Collections.unmodifiableMap(result);
		return toMultiValueMap(unmodifiableMap);
	}
344012
public static <K, V> Map<K, V> unmodifiableCopy(
        Map<? extends K, ? extends V> map)
    {
        return Collections.<K, V>unmodifiableMap(
            new LinkedHashMap<K, V>(map));
    }
536391
public static <A, B> Map<A, B> removeNullEntries(Map<A, B> map) {

        HashMap<A, B> result = new HashMap<A, B>();

        for (Map.Entry<A, B> entry : map.entrySet()) {
            if (entry.getValue() != null) {
                result.put(entry.getKey(), entry.getValue());
            }
        }
        return result;
    }