Java Utililty Methods Map Copy

List of utility methods to do Map Copy

Description

The list of methods to do Map Copy are organized into topic(s).

Method

MapcopyOptions(Map options)
copy Options
return options != null ? new HashMap<String, Object>(options) : new HashMap<String, Object>();
MapcopyParameters(Map parameters)
copy Parameters
Map<String, Object> ps = new HashMap<>();
if (parameters != null)
    ps.putAll(parameters);
return ps;
voidcopyPropertiesToMap(Properties source, Map target)
This function copies all mappings from source properties to target map.
if (source != null) {
    Iterator<Entry<Object, Object>> iterator = source.entrySet().iterator();
    Entry<Object, Object> entry = null;
    String key = null;
    String value = null;
    while (iterator.hasNext()) {
        entry = iterator.next();
        key = (String) entry.getKey();
...
java.util.MapcopySafelyToObjectToObjectMap(java.util.Map map)
copy Safely To Object To Object Map
java.util.Map<Object, Object> castedCopy = new java.util.LinkedHashMap<Object, Object>();
if (map == null) {
    return castedCopy;
java.util.Iterator<?> it = map.keySet().iterator();
while (it.hasNext()) {
    Object nextKey = it.next();
    castedCopy.put(nextKey, map.get(nextKey));
...
MapcopyStringMap(Map initParams)
copy String Map
return new HashMap<String, String>(initParams);
voidcopyUntilFull(final Map source, final Map dest1, Map overflow, final int dest1Capacity)
Copies the entries from source to dest1 until dest1 has reached size dest1Capacity.
for (final Map.Entry<? extends T, ? extends U> srcEntry : source.entrySet()) {
    if (dest1.size() < dest1Capacity) {
        dest1.put(srcEntry.getKey(), srcEntry.getValue());
    } else {
        overflow.put(srcEntry.getKey(), srcEntry.getValue());
voidcopyValue(Map source, Map target, K key)
Copy value.
target.put(key, source.get(key));
booleancopyValueIfExist(Map source, K sourceKey, Map target, K targetKey)
Copy value if it exists (is not null) from the source map.
V v = source.get(sourceKey);
if (v != null) {
    target.put(targetKey, v);
    return true;
return false;
booleancopyValueIfExist(Map source, Map target, K key)
Copy value from the source map to the target map only if the value exists in the source map.
V v = source.get(key);
if (v != null) {
    target.put(key, v);
    return true;
return false;
MapdeepCopy(Map map)
deep Copy
Map result = new HashMap();
for (Object o : map.keySet()) {
    result.put(o, map.get(o));
result = Collections.unmodifiableMap(result);
return result;