Here you can find the source of mergePropertiesToMap(Properties properties, Map
Parameter | Description |
---|---|
properties | a parameter |
map | a parameter |
overwrite | a parameter |
public static <K, V> Map<K, V> mergePropertiesToMap(Properties properties, Map<K, V> map, boolean overwrite)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import java.util.Properties; public class Main { /**//from w ww .j a v a 2s .c o m * Returns new Map * * @param properties * @param map * @param overwrite * @return */ public static <K, V> Map<K, V> mergePropertiesToMap(Properties properties, Map<K, V> map, boolean overwrite) { 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; } }