Package io.github.connellite.collections
Interface MultiValueMap<K,V>
- Type Parameters:
K- the key typeV- the value element type
- All Known Implementing Classes:
LinkedMultiValueHashMap,MultiValueHashMap
Extension of the
Map interface that stores multiple values.-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoidAdd the given single value to the current list of values for the given key.voidaddAll(MultiValueMap<K, V> values) Add all the values of the givenMultiValueMapto the current values.voidAdd all the values of the given list to the current list of values for the given key.default voidaddIfAbsent(K key, V value) Add the given value, only when the map does not contain the given key.Return the first value for the given key.voidSet the given single value under the given key.voidSet the given values under their associated key.Return aMapwith the first values contained in thisMultiValueMap.Return an unmodifiable view of this map with immutable value lists.Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Method Details
-
getFirst
Return the first value for the given key.- Parameters:
key- the key- Returns:
- the first value for the specified key, or
null
-
add
Add the given single value to the current list of values for the given key.- Parameters:
key- the keyvalue- the value to be added
-
addAll
Add all the values of the given list to the current list of values for the given key.- Parameters:
key- they keyvalues- the values to be added
-
addAll
Add all the values of the givenMultiValueMapto the current values.- Parameters:
values- the values to be added
-
set
Set the given single value under the given key.- Parameters:
key- the keyvalue- the value to set
-
setAll
Set the given values under their associated key.- Parameters:
values- the values
-
toSingleValueMap
Return aMapwith the first values contained in thisMultiValueMap.- Returns:
- a single value representation of this map
-
toUnmodifiableMap
Return an unmodifiable view of this map with immutable value lists. The returned map and its list values cannot be modified; changes to this map are not reflected in the returned instance.- Returns:
- unmodifiable map with copied value lists
-
addIfAbsent
Add the given value, only when the map does not contain the given key.- Parameters:
key- the keyvalue- the value to be added
-