Java Utililty Methods Map Remove

List of utility methods to do Map Remove

Description

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

Method

ObjectremoveFromMapValues(final Map map, final Object value)
Removes the specified reader/writer from the values of the specified reader/writer map.
synchronized (map) {
    final Collection entries = map.entrySet();
    for (final Iterator iter = entries.iterator(); iter.hasNext();) {
        final Map.Entry entry = (Entry) iter.next();
        if (entry.getValue().equals(value)) {
            final Object key = entry.getKey();
            iter.remove();
            return key;
...
List>removeGeneric(List> list)
remove Generic
if (list == null) {
    return null;
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
for (int i = 0; i < list.size(); i++) {
    Map<String, T> map = list.get(i);
    Map<String, Object> newMap = new HashMap<String, Object>();
    newMap.putAll(map);
...
voidremoveHeader(Map headers, String header)
remove Header
if (header != null && headers.containsKey(header)) {
    headers.remove(header);
List>removeKeyAndConvertToListOfMaps(Object obj, String key)
removeKeyAndConvertToListOfMaps - This method is written to meet the requirement for BML Indigo.
List<Map<Object, Object>> listofMaps = null;
if (obj instanceof Map) {
    listofMaps = new ArrayList<Map<Object, Object>>();
    Map<Object, Object> map = (Map<Object, Object>) obj;
    if (map.containsKey(key))
        map.remove(key);
    for (Entry<Object, Object> mapEntry : map.entrySet()) {
        Map<Object, Object> listmap = new HashMap<Object, Object>();
...
voidremoveKeys(Collection keys, Map map)
remove Keys
for (Iterator i = keys.iterator(); i.hasNext();) {
    Object key = (Object) i.next();
    map.remove(key);
voidremoveKeysWithPrefix(Map map, String prefix)
remove Keys With Prefix
Iterator<Map.Entry<String, Object>> iter = map.entrySet().iterator();
while (iter.hasNext()) {
    Map.Entry<String, Object> e = iter.next();
    if (e.getKey().startsWith(prefix)) {
        iter.remove();
voidremoveMapEntryFromPreferenceStoredMap(String keyOfPreference, String keyInMap)
Removes map entry with key keyInMapfrom the map whose key is keyOfPreference
Map map = getPreferenceStoredMap(keyOfPreference);
if (map.containsKey(keyInMap)) {
    map.remove(keyInMap);
setPreferenceStoredMap(keyOfPreference, map);
MapremoveNamespaces(Map properties)
remove Namespaces
HashMap props = new HashMap(properties.size());
Map.Entry entry;
for (Iterator iter = properties.entrySet().iterator(); iter.hasNext();) {
    entry = (Map.Entry) iter.next();
    props.put(removeNamespacePrefix((String) entry.getKey()), entry.getValue());
return props;
voidremoveNode(Map map, List pathItems)
remove Node
Map<String, Object> m = map;
Map<String, Object> subm = m;
String name = null;
for (String pathItem : pathItems) {
    name = pathItem;
    m = subm;
    subm = (Map<String, Object>) m.get(name);
    if (subm == null)
...
MapremoveNullEntries(Map map)
Returns a new map with all entries of the input map except those which have a value of null.

HashMap<A, B> result = new HashMap<A, B>();
for (Map.Entry<A, B> entry : map.entrySet()) {
    if (entry.getValue() != null) {
        result.put(entry.getKey(), entry.getValue());
return result;