List of utility methods to do Map Copy
Map | copyMap(Map Makes a true copy of provided oMap instance. if (oMap == null) { return null; Map<K, V> cMap = new HashMap<>(oMap.size()); for (Map.Entry<K, V> ome : oMap.entrySet()) { V oVal = ome.getValue(); if (oVal instanceof Map) { oVal = (V) copyMap((Map<K, V>) oVal); ... |
HashMap | copyMap(Map copy Map HashMap<String, String> result = new HashMap<String, String>(); for (Map.Entry<String, Object> entry : map.entrySet()) { String value = null; if (entry.getValue() != null) { value = entry.getValue().toString(); result.put(entry.getKey(), value); return result; |
Map | copyMap(Map copy Map if (m == null || m.size() == 0) { return new HashMap<T, U>(); } else { return new HashMap<T, U>(m); |
Map | copyMap(Object object) copy Map if (!(object instanceof Map)) { return null; Map<?, ?> map = (Map<?, ?>) object; Map<String, Object> temp = new HashMap<>(); for (Map.Entry<?, ?> entry : map.entrySet()) { if (entry.getKey() instanceof String) { temp.put((String) entry.getKey(), entry.getValue()); ... |
Map | copyMapButFailOnNull(Map extends K, ? extends V> entries) Copy each map entry to a new map but check that each key and value isn't null. Map<K, V> entriesToRemap = new HashMap<>(entries.size()); entries.forEach((k, v) -> { if (k == null || v == null) { throw new NullPointerException(); entriesToRemap.put(k, v); }); return entriesToRemap; ... |
Map | copyMapWithoutEmpties(Map extends Object, ? extends Object> original) copy Map Without Empties Map<Object, Object> result = new HashMap<Object, Object>(); Set<?> keys = original.keySet(); for (Object key : keys) { Object value = original.get(key); if (value == null || value.toString().length() < 1) continue; result.put(key, value); return result; |
Map | copyOf( Map Returns a copy of the Map of Maps parameter. Map<KEY_1, Map<KEY_2, VALUE>> result = new HashMap<>(); for (Map.Entry<KEY_1, ? extends Map<KEY_2, VALUE>> entry : map.entrySet()) { result.put(entry.getKey(), new HashMap<>(entry.getValue())); return result; |
Map | copyOf(final Map copy Of final Map<K, V> copy = new LinkedHashMap<>(); copy.putAll(map); return copy; |
Map | copyOf(Map copy Of Map<T, K> dst = new HashMap<T, K>(); copy(src, dst); return dst; |
Map | copyOnWritePut(K k, V v, Map copy On Write Put Map<K, V> map = new IdentityHashMap<K, V>(source); map.put(k, v); return map; |