Java Map Put putAllRecursively(Map destination, Map source)

Here you can find the source of putAllRecursively(Map destination, Map source)

Description

Puts all the values in the given source Map into the destination Map , merging any Map values.

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
public static void putAllRecursively(Map<String, Object> destination, Map<String, Object> source) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;

public class Main {
    /**//from   w ww  . ja  v  a 2s.  c o m
     * Puts all the values in the given source {@code Map} into the
     * destination {@code Map}, merging any {@code Map} values.
     */
    @SuppressWarnings("unchecked")
    public static void putAllRecursively(Map<String, Object> destination, Map<String, Object> source) {
        for (Map.Entry<String, Object> e : source.entrySet()) {
            String key = e.getKey();
            Object srcValue = e.getValue();
            Object dstValue = destination.get(key);
            if (srcValue instanceof Map && dstValue instanceof Map) {
                putAllRecursively((Map<String, Object>) dstValue, (Map<String, Object>) srcValue);
            } else {
                destination.put(key, srcValue);
            }
        }
    }
}

Related

  1. putAllIfNew(Map dest, Map source)
  2. putAllIfNotNull(final Map map, final Map m)
  3. putAllNewInMap(Map original, Map newStuff)
  4. putAllNonNullValues(Map source, Map target)
  5. putAllObjects(Map targetMap, Map sourceMap)
  6. putAllTransposed( Map> source_key_valueSet, Map output_value_key)
  7. putAsCollection(K key, V value, Map map)
  8. putAsStringIfNotNull(Map properties, String key, Object value)
  9. putAt(LinkedHashMap map, K key, V value, int pos)