Java Map Merge mergeMap(Map map, Object[]... pairs)

Here you can find the source of mergeMap(Map map, Object[]... pairs)

Description

Merges the map with the new value and returns a new map.

License

Open Source License

Declaration

@SuppressWarnings("unchecked")
public static Map mergeMap(Map map, Object[]... pairs) 

Method Source Code

//package com.java2s;
import java.util.HashMap;
import java.util.Map;

public class Main {
    /**//from   w  w w  . j av a 2  s .c o m
     * Merges the map with the new value and returns a new map.
     */
    @SuppressWarnings("unchecked")
    public static Map mergeMap(Map map, Object[]... pairs) {
        if (map == null) {
            map = new HashMap();
        }
        Map newMap = new HashMap(map);
        for (Object[] pair : pairs) {
            newMap.put(pair[0], pair[1]);
        }
        return newMap;
    }
}

Related

  1. mergeFamilies(Map familySource, Map familyTarget)
  2. mergeFixedValueConditions(Map> left, Map> right)
  3. mergeIfAbsent(Map map, Map toMerge)
  4. mergeImportedPermissionsWithExistingPermissions( Map> existingRoleIdsToActionIds, Map importedRoleIdsToActionIds)
  5. mergeListWithMap(List from, Map to)
  6. mergeMap(Map primaryValues, Map defaultValues)
  7. mergeMap(Map first, Map second)
  8. mergeMapIntoMap(Map> source, Map> destination)
  9. mergeMapList(List> list)