List of utility methods to do Map Put
Map | putAllIfNew(Map Same as putall, except if the property already exists in the dest map, don't move it. if (dest == null) return source; if (source == null) return dest; for (String key : source.keySet()) { if (dest.get(key) == null) dest.put(key, source.get(key)); return dest; |
boolean | putAllIfNotNull(final Map super K, ? super V> map, final Map extends K, ? extends V> m) put All If Not Null if ((map == null) || (m == null)) { return false; map.putAll(m); return true; |
void | putAllNewInMap(Map Puts the values of 2 maps together such that the values from the newStuff map are added to the original map only if they are not already in the the original if (original == null) { throw new IllegalArgumentException("original map cannot be null"); if (newStuff != null) { if (original.isEmpty()) { original.putAll(newStuff); } else { for (Entry<T, S> entry : newStuff.entrySet()) { ... |
Set | putAllNonNullValues(Map source, Map target) Puts all entries from map source to map target whose values are non-null. Iterator entries = source.entrySet().iterator(); Set nullKeys = new HashSet(); while (entries.hasNext()) { Map.Entry entry = (Map.Entry) entries.next(); if (entry.getValue() != null) { target.put(entry.getKey(), entry.getValue()); } else { nullKeys.add(entry.getKey()); ... |
Map | putAllObjects(Map put All Objects if (targetMap == null && sourceMap == null) { return new HashMap<T, U>(); if (targetMap == null) { return new HashMap<T, U>(sourceMap); if (sourceMap == null) { return targetMap; ... |
void | putAllRecursively(Map Puts all the values in the given source Map into the destination Map , merging any Map values. for (Map.Entry<String, Object> e : source.entrySet()) { String key = e.getKey(); Object srcValue = e.getValue(); Object dstValue = destination.get(key); if (srcValue instanceof Map && dstValue instanceof Map) { putAllRecursively((Map<String, Object>) dstValue, (Map<String, Object>) srcValue); } else { destination.put(key, srcValue); ... |
void | putAllTransposed(Map Takes a Map that goes from Object to Set, and fills in the transpose for (Iterator<Object> it = source_key_valueSet.keySet().iterator(); it.hasNext();) { Object key = it.next(); Set<Object> values = source_key_valueSet.get(key); for (Iterator<Object> it2 = values.iterator(); it2.hasNext();) { Object value = it2.next(); output_value_key.put(value, key); |
void | putAsCollection(K key, V value, Map put As Collection List<V> list = new ArrayList<V>(); if (map.containsKey(key)) { list = (List<V>) map.get(key); list.add(value); map.put(key, (L) list); |
void | putAsStringIfNotNull(Map put As String If Not Null if (value == null) return; properties.put(key, toString(value)); |
void | putAt(LinkedHashMap put At Iterator<Entry<K, V>> ei = map.entrySet().iterator(); LinkedHashMap<K, V> pre = new LinkedHashMap<>(); LinkedHashMap<K, V> post = new LinkedHashMap<>(); for (int i = 0; i < pos; i++) { if (!ei.hasNext()) break; Entry<K, V> tmpE = ei.next(); pre.put(tmpE.getKey(), tmpE.getValue()); ... |