Java Utililty Methods Map Clone

List of utility methods to do Map Clone

Description

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

Method

Mapclone(Map aMap)
Clones a map.
if (aMap instanceof HashMap)
    return (Map) ((HashMap) aMap).clone();
if (aMap instanceof Hashtable)
    return (Map) ((Hashtable) aMap).clone();
return aMap == null ? null : new HashMap(aMap);
Mapclone(Map from, Map to)
clone
Iterator keyIt = from.keySet().iterator();
while (keyIt.hasNext()) {
    Object key = keyIt.next();
    Object value = from.get(key);
    to.put(key, value);
return to;
Mapclone(Map configurationValues)
Make a clone of the configuration values.
if (configurationValues == null) {
    return null;
if (Properties.class.isInstance(configurationValues)) {
    return (Properties) ((Properties) configurationValues).clone();
HashMap clone = new HashMap();
for (Map.Entry entry : configurationValues.entrySet()) {
...
Mapclone(Map map1)
clone
Map<K, V> map2 = new HashMap<K, V>(map1.size());
for (Map.Entry<K, V> e : map1.entrySet()) {
    map2.put(e.getKey(), e.getValue());
return map2;
HashMapclone(Map origMap)
returns a new HashMap containing a shallow clone of the original map.
HashMap<K, V> newMap = new HashMap<K, V>();
if (origMap != null && origMap.size() > 0) {
    newMap.putAll(origMap);
return newMap;
Mapclone(Map map)
clone
if (map.isEmpty()) {
    return Collections.emptyMap();
Map<String, String[]> copy = new HashMap<String, String[]>(map);
for (Map.Entry<String, String[]> entry : copy.entrySet()) {
    entry.setValue(entry.getValue().clone());
return copy;
...
MapcloneDefaults(Map defaults)
clone Defaults
Map<String, Object> cloned = new HashMap<String, Object>();
for (Map.Entry entry : defaults.entrySet()) {
    cloned.put((String) entry.getKey(), entry.getValue());
return cloned;
MapcloneMap(final Map m)
clone Map
if (m == null) {
    return null;
final Map<String, Object> ret = new HashMap<String, Object>(m.size());
for (final Entry<String, Object> e : m.entrySet()) {
    ret.put(String.valueOf(e.getKey()), e.getValue());
return ret;
...
MapcloneMap(Map map)
Creates a duplicate of the specified map
Map<K, V> tempUpdates = new HashMap<K, V>();
tempUpdates.putAll(map);
return tempUpdates;
MapcloneMap(Map orig)
Shallow clone
if (orig == null) {
    return null;
Map<K, V> clone = new HashMap<K, V>();
for (Entry<K, V> origEntry : orig.entrySet()) {
    clone.put(origEntry.getKey(), origEntry.getValue());
return clone;
...