K
- the type of keys maintained by this map.V
- the type of mapped values.public abstract class AbstractMultivaluedMap<K,V> extends Object implements MultivaluedMap<K,V>, Serializable
MultivaluedMap
that is backed by a [key, multi-value] store represented
as a Map<K, List<V>>
.Modifier and Type | Field and Description |
---|---|
protected Map<K,List<V>> |
store
Backing store for the [key, multi-value] pairs.
|
Constructor and Description |
---|
AbstractMultivaluedMap(Map<K,List<V>> store)
Initialize the backing store in the abstract parent multivalued map implementation.
|
Modifier and Type | Method and Description |
---|---|
void |
add(K key,
V value)
Add a value to the current list of values for the supplied key.
|
void |
addAll(K key,
List<V> valueList)
Add all the values from the supplied value list to the current list of values for the supplied key.
|
void |
addAll(K key,
V... newValues)
Add multiple values to the current list of values for the supplied key.
|
void |
addFirst(K key,
V value)
Add a value to the first position in the current list of values for the supplied key.
|
protected void |
addFirstNull(List<V> values)
Define the behavior for adding a
null values to the first position in the value list. |
protected void |
addNull(List<V> values)
Define the behavior for adding a
null values to the value list. |
void |
clear() |
boolean |
containsKey(Object key) |
boolean |
containsValue(Object value) |
Set<Map.Entry<K,List<V>>> |
entrySet() |
boolean |
equals(Object o) |
boolean |
equalsIgnoreValueOrder(MultivaluedMap<K,V> omap)
Compare the specified map with this map for equality modulo the order of values for each key.
|
List<V> |
get(Object key) |
V |
getFirst(K key)
A shortcut to get the first value of the supplied key.
|
protected List<V> |
getValues(K key)
Return a non-null list of values for a given key.
|
int |
hashCode() |
boolean |
isEmpty() |
Set<K> |
keySet() |
List<V> |
put(K key,
List<V> value) |
void |
putAll(Map<? extends K,? extends List<V>> m) |
void |
putSingle(K key,
V value)
Set the value for the key to be a one item list consisting of the supplied value.
|
List<V> |
remove(Object key) |
int |
size() |
String |
toString() |
Collection<List<V>> |
values() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll
public AbstractMultivaluedMap(Map<K,List<V>> store)
store
- the backing Map
to be used as a [key, multi-value] store. Must not be null
.NullPointerException
- in case the underlying store
parameter is null
.public final void putSingle(K key, V value)
Set the value for the key to be a one item list consisting of the supplied value. Any existing values will be replaced.
NOTE: This implementation ignoresnull
values; A supplied value of null
is ignored and not added to
the purged value list. As a result of such operation, empty value list would be registered for the supplied key.
Overriding implementations may modify this behavior by redefining the addNull(java.util.List)
method.putSingle
in interface MultivaluedMap<K,V>
key
- the keyvalue
- the single value of the key. If the value is null
it will be ignored.protected void addNull(List<V> values)
Define the behavior for adding a null
values to the value list.
null
values are ignored. Overriding implementations may modify
this behavior by providing their own definitions of this method.values
- value list where the null
value addition is being requested.protected void addFirstNull(List<V> values)
Define the behavior for adding a null
values to the first position in the value list.
null
values are ignored. Overriding implementations may modify
this behavior by providing their own definitions of this method.values
- value list where the null
value addition is being requested.public final void add(K key, V value)
Add a value to the current list of values for the supplied key.
NOTE: This implementation ignoresnull
values; A supplied value of null
is ignored and not added to
the value list. Overriding implementations may modify this behavior by redefining the
addNull(java.util.List)
method.add
in interface MultivaluedMap<K,V>
key
- the keyvalue
- the value to be added.public final void addAll(K key, V... newValues)
Add multiple values to the current list of values for the supplied key. If the supplied array of new values is empty,
method returns immediately. Method throws a NullPointerException
if the supplied array of values is
null
.
null
values; Any of the supplied values of null
is ignored and not
added to the value list. Overriding implementations may modify this behavior by redefining the
addNull(java.util.List)
method.addAll
in interface MultivaluedMap<K,V>
key
- the key.newValues
- the values to be added.NullPointerException
- if the supplied array of new values is null
.public final void addAll(K key, List<V> valueList)
Add all the values from the supplied value list to the current list of values for the supplied key. If the supplied
value list is empty, method returns immediately. Method throws a NullPointerException
if the supplied array
of values is null
.
null
values; Any null
value in the supplied value list is ignored
and not added to the value list. Overriding implementations may modify this behavior by redefining the
addNull(java.util.List)
method.addAll
in interface MultivaluedMap<K,V>
key
- the key.valueList
- the list of values to be added.NullPointerException
- if the supplied value list is null
.public final V getFirst(K key)
MultivaluedMap
getFirst
in interface MultivaluedMap<K,V>
key
- the keypublic final void addFirst(K key, V value)
Add a value to the first position in the current list of values for the supplied key.
NOTE: This implementation ignoresnull
values; A supplied value of null
is ignored and not added to
the purged value list. Overriding implementations may modify this behavior by redefining the
addFirstNull(java.util.List)
method.addFirst
in interface MultivaluedMap<K,V>
key
- the keyvalue
- the value to be added.protected final List<V> getValues(K key)
Return a non-null list of values for a given key. The returned list may be empty.
If there is no entry for the key in the map, a new emptyList
instance is created, registered within the map
to hold the values of the key and returned from the method.key
- the key.null
.public int hashCode()
This implementation delegates the method call to to the the underlying [key, multi-value] store.
public boolean equals(Object o)
This implementation delegates the method call to to the the underlying [key, multi-value] store.
public boolean containsValue(Object value)
containsValue
in interface Map<K,List<V>>
public boolean containsKey(Object key)
containsKey
in interface Map<K,List<V>>
public boolean equalsIgnoreValueOrder(MultivaluedMap<K,V> omap)
MultivaluedMap
equalsIgnoreValueOrder
in interface MultivaluedMap<K,V>
omap
- map to be compared to this one.Copyright © 2018,2020 Eclipse Foundation.
Use is subject to license terms.