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

booleanremove(Map map, String key)
remove
Iterator<?> it = map.keySet().iterator();
while (it.hasNext()) {
    Object keyObject = it.next();
    if (keyObject instanceof String) {
        String k = (String) keyObject;
        if (k.compareTo(key) == 0) {
            it.remove();
            return true;
...
booleanremove(Map> map, K key, V value)
remove
boolean removed = false;
Set<V> values = map.get(key);
if (values != null) {
    removed = values.remove(value);
    if (values.isEmpty())
        map.remove(key);
return removed;
...
voidremove(Map map, Collection keys)
 
if (map == null || map.isEmpty()) {
    return;
if (keys == null || keys.isEmpty()) {
    return;
for (K key : keys) {
    if (key == null) {
...
Vremove(Map map, K key)
Removes the mapping for a key from this map if it is present.
if (map == null)
    return null;
return map.remove(key);
voidremoveAll(final Map target, final Iterable keys, Collection values)
Removes all the given keys from the given map and adds their corresponding values to the given collection.
if (keys != null) {
    removeAll(target, keys.iterator(), values);
voidremoveAll(Map map, Set keys)
remove All
for (K k : keys) {
    map.remove(k);
booleanremoveAllFromCollection(Map> map, Object key, Collection values)
remove All From Collection
Collection list = (Collection) map.get(key);
if (list == null) {
    return false;
} else {
    boolean result = list.removeAll(values);
    if (list.isEmpty()) {
        map.remove(key);
    return result;
MapremoveAllNullValueEntry(Map source)
remove All Null Value Entry
if (null == source) {
    return new HashMap<R, T>();
Map<R, T> map = new HashMap<R, T>();
for (Entry<R, T> entry : source.entrySet()) {
    if (null == entry.getValue() || null == entry.getKey()) {
        continue;
    map.put(entry.getKey(), entry.getValue());
return map;
booleanremoveAndCleanFromCollectionMap(KeyT key, ValT toBeRemoved, Map> map)
NOTE Same as removeObjectFromCollectionMap but remove key if Collection is empty.
Collection<ValT> obj = map.get(key);
if (obj == null) {
    return false;
Collection<ValT> coll = obj;
final boolean ret = coll.remove(toBeRemoved);
if (coll.isEmpty()) {
    map.remove(key);
...
voidremoveApiUuidMap(String apiName)
remove Api Uuid Map
apiUuidMap.remove(apiName);