List of utility methods to do Map Merge
Map | mergeMaps(Map merge Maps final Map<String, T> res = new HashMap<>(); res.putAll(map1); res.putAll(map2); return res; |
Map | mergeMapsIgnoreDuplicateKeys(Map Generic map merge logic for (Map.Entry<T1, T2> entry : second.entrySet()) { T1 key = entry.getKey(); if (!first.containsKey(key)) { first.put(key, entry.getValue()); return first; |
Map super TKey,Integer> | mergeMapWithAdd(Map merge Map With Add for (Entry<? extends TKey, ? extends Integer> entry2 : source.entrySet()) { TKey key2 = entry2.getKey(); int val2 = entry2.getValue(); if (target.containsKey(key2)) { int val1 = target.get(key2); target.put(key2, val1 + val2); } else { target.put(key2, val2); ... |
Map | mergeNestableMap(Map Deep-merge a map into another map returning a result map. Map<String, Object> result = new LinkedHashMap<String, Object>(original); for (Map.Entry<String, Object> additionalEntry : additional.entrySet()) { String name = additionalEntry.getKey(); Object additionalValue = additionalEntry.getValue(); Object originalValue = original.get(name); Object newValue; if ((originalValue instanceof Map) && (additionalValue instanceof Map)) { Map<String, Object> innerAdditional = (Map<String, Object>) additionalValue; ... |
Map | mergeNsPrefixes(final Map Creates a new Map object containing all prefixes from both specified maps. Map<String, String> mergedPrefixes = new HashMap<String, String>(); mergedPrefixes.putAll(additionalPrefixes); mergedPrefixes.putAll(prioritaryPrefixes); return mergedPrefixes; |
void | mergeOptions(Map merge Options ssio.forEach((k, v) -> { if (v != null) { Map<String, String> options = allOptions.get(k); if (options == null) { allOptions.put(k, v); } else { options.putAll(v); }); |
void | mergePermMap(Map merge Perm Map Set<Entry<String, Set<T>>> subEntrySet = subPermMap.entrySet(); Iterator<Entry<String, Set<T>>> subEntryIterator = subEntrySet.iterator(); while (subEntryIterator.hasNext()) { Entry<String, Set<T>> subEntry = subEntryIterator.next(); String permTypeName = subEntry.getKey(); Set<T> permValueSet = subEntry.getValue(); if (permMap.containsKey(permTypeName)) { permMap.get(permTypeName).addAll(permValueSet); ... |
Map | mergePropertiesToMap(Properties properties, Map Returns new Map Map<K, V> resultMap = new HashMap<>(); for (K mapKey : map.keySet()) { resultMap.put(mapKey, map.get(mapKey)); for (Object propertyKey : properties.keySet()) { if ((overwrite) || (false == resultMap.containsKey((K) propertyKey))) { resultMap.put((K) propertyKey, (V) properties.get((K) propertyKey)); return resultMap; |
void | mergeResourceBundle(final Map map, final String path) Merge the resource bundle at the path into the specified map. final ResourceBundle bundle = ResourceBundle.getBundle(path); final Enumeration<String> keyEnum = bundle.getKeys(); while (keyEnum.hasMoreElements()) { final String key = keyEnum.nextElement(); final String assignment = bundle.getString(key); if (key.startsWith("+")) { final String baseKey = key.substring(1); final String initialAssignment = (String) map.get(baseKey); ... |
String | mergeTemplate(String template, Map Takes a template and replaces the segment keys with the segment values, keys should not have {} around them yet as these will be added around each key in the segments map if (template == null || "".equals(template) || segments == null) { throw new IllegalArgumentException( "Cannot operate on null template/segments, template must not be empty"); int vars = 0; char[] chars = template.toCharArray(); for (int i = 0; i < chars.length; i++) { if (chars[i] == '{') { ... |