Here you can find the source of mergeMaps(Map
@SuppressWarnings("unchecked") private static Map<String, Object> mergeMaps(Map<String, Object> defaultMap, Map<String, Object> customMap)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.util.Map; public class Main { /**//from www .j a va2 s. co m * Recursively merges a custom map into a default map, and returns the merged result. * * <p>All keys in the default map that are also specified in the custom map are overridden with * the custom map's value. This runs recursively on all contained maps. */ @SuppressWarnings("unchecked") private static Map<String, Object> mergeMaps(Map<String, Object> defaultMap, Map<String, Object> customMap) { for (String key : defaultMap.keySet()) { if (!customMap.containsKey(key)) { continue; } Object newValue; if (defaultMap.get(key) instanceof Map && !key.endsWith("Map")) { newValue = mergeMaps((Map<String, Object>) defaultMap.get(key), (Map<String, Object>) customMap.get(key)); } else { newValue = customMap.get(key); } defaultMap.put(key, newValue); } return defaultMap; } }