Java Map Remove removeAllFromCollection(Map> map, Object key, Collection values)

Here you can find the source of removeAllFromCollection(Map> map, Object key, Collection values)

Description

remove All From Collection

License

Apache License

Declaration

@SuppressWarnings("unchecked")
    public static <K, V> boolean removeAllFromCollection(Map<K, ? extends Collection<? super V>> map, Object key,
            Collection<V> values) 

Method Source Code

//package com.java2s;
/**//from  w w  w.java  2s  .  c om
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
    
http://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import java.util.Collection;

import java.util.Map;

public class Main {
    @SuppressWarnings("unchecked")
    public static <K, V> boolean removeAllFromCollection(Map<K, ? extends Collection<? super V>> map, Object key,
            Collection<V> values) {
        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;
        }
    }
}

Related

  1. remove(Map> map, K key, V value)
  2. remove(Map map, Collection keys)
  3. remove(Map map, K key)
  4. removeAll(final Map target, final Iterable keys, Collection values)
  5. removeAll(Map map, Set keys)
  6. removeAllNullValueEntry(Map source)
  7. removeAndCleanFromCollectionMap(KeyT key, ValT toBeRemoved, Map> map)
  8. removeApiUuidMap(String apiName)
  9. removeClassFromMap(final Map the_map, final String the_class_name)