org.apache.commons.collections4.multimap

## Class AbstractListValuedMap<K,V>

- java.lang.Object
- - org.apache.commons.collections4.multimap.AbstractMultiValuedMap<K,V>
  - - org.apache.commons.collections4.multimap.AbstractListValuedMap<K,V>

- All Implemented Interfaces:
    ListValuedMap<K,V>, MultiValuedMap<K,V>
  Direct Known Subclasses:
    ArrayListValuedHashMap

      public abstract class AbstractListValuedMap<K,V>
      extends AbstractMultiValuedMap<K,V>
      implements ListValuedMap<K,V>

  Abstract implementation of the `ListValuedMap` interface to simplify the creation of subclass implementations.

  Subclasses specify a Map implementation to use as the internal storage and the List implementation to use as values.

  Since:
    4.1
  Version:
    $Id: AbstractListValuedMap.java 1715695 2015-11-22 21:11:49Z tn $

- - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `AbstractListValuedMap()` Constructor needed for subclass serialisation.
    `protected` | `AbstractListValuedMap(Map<K,? extends List<V>> map)` A constructor that wraps, not copies

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract List<V>` | `createCollection()` Creates a new value collection using the provided factory.
    `List<V>` | `get(K key)` Gets the list of values associated with the specified key.
    `protected Map<K,List<V>>` | `getMap()` Gets the map being wrapped.
    `List<V>` | `remove(Object key)` Removes all values associated with the specified key.

    - ### Methods inherited from class org.apache.commons.collections4.multimap.AbstractMultiValuedMap

      `asMap, clear, containsKey, containsMapping, containsValue, doReadObject, doWriteObject, entries, equals, hashCode, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, setMap, size, toString, values`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.apache.commons.collections4.MultiValuedMap

      `asMap, clear, containsKey, containsMapping, containsValue, entries, isEmpty, keys, keySet, mapIterator, put, putAll, putAll, putAll, removeMapping, size, values`

- - ### Constructor Detail

    - #### AbstractListValuedMap

          protected AbstractListValuedMap()

      Constructor needed for subclass serialisation.

    - #### AbstractListValuedMap

          protected AbstractListValuedMap(Map<K,? extends List<V>> map)

      A constructor that wraps, not copies
      Parameters:
        `map` - the map to wrap, must not be null
      Throws:
        `NullPointerException` - if the map is null

  - ### Method Detail

    - #### getMap

          protected Map<K,List<V>> getMap()

      Description copied from class: `AbstractMultiValuedMap`
      Gets the map being wrapped.
      Overrides:
        `getMap` in class `AbstractMultiValuedMap<K,V>`
      Returns:
        the wrapped map

    - #### createCollection

          protected abstract List<V> createCollection()

      Creates a new value collection using the provided factory.
      Specified by:
        `createCollection` in class `AbstractMultiValuedMap<K,V>`
      Returns:
        a new list

    - #### get

          public List<V> get(K key)

      Gets the list of values associated with the specified key. This would return an empty list in case the mapping is not present
      Specified by:
        `get` in interface `ListValuedMap<K,V>`
      Specified by:
        `get` in interface `MultiValuedMap<K,V>`
      Overrides:
        `get` in class `AbstractMultiValuedMap<K,V>`
      Parameters:
        `key` - the key to retrieve
      Returns:
        the `List` of values, will return an empty `List` for no mapping

    - #### remove

          public List<V> remove(Object key)

      Removes all values associated with the specified key.

      A subsequent `get(Object)` would return an empty list.

      Specified by:
        `remove` in interface `ListValuedMap<K,V>`
      Specified by:
        `remove` in interface `MultiValuedMap<K,V>`
      Overrides:
        `remove` in class `AbstractMultiValuedMap<K,V>`
      Parameters:
        `key` - the key to remove values from
      Returns:
        the `List` of values removed, will return an empty, unmodifiable list for no mapping found.

Copyright © 2001–2015 The Apache Software Foundation. All rights reserved.