K - the type of keys maintained by this map.V - the type of mapped values.abstract class AbstractMultivaluedMap<K,V> extends Object implements MultivaluedMap<K,V>
MultivaluedMap that is backed by a [key, multi-value] store represented
as a Map 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 key's value 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, waitcompute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAllAbstractMultivaluedMap(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)
Any existing values will bereplaced.
NOTE: This implementation ignores null 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 keyprotected void addNull(List<V> values)
null values to the value list.
Default implementation is a no-op, i.e. the 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)
null values to the first position in the value list.
Default implementation is a no-op, i.e. the 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)
NOTE: This implementation ignores null 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.@SafeVarargs public final void addAll(K key, V... newValues)
NullPointerException if the supplied array of values
is null.
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.
NOTE: This implementation ignores 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.public final void addAll(K key, List<V> valueList)
NullPointerException if the
supplied array of values is null.
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.
NOTE: This implementation ignores 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.public final V getFirst(K key)
getFirst in interface MultivaluedMap<K,V>key - the keypublic final void addFirst(K key, V value)
NOTE: This implementation ignores null 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)
If there is no entry for the key in the map, a new empty java.util.List 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)
equalsIgnoreValueOrder in interface MultivaluedMap<K,V>omap - map to be compared to this one.Copyright © 2014 Sven Strittmatter. All Rights Reserved.