Package it.tidalwave.util
Interface TypeSafeMultiMap
- All Superinterfaces:
Iterable<Map.Entry<Key<?>,Collection<?>>>
A map that is type safe, i.e. the pairs (key, value) are type-checked, and can contain multiple values, i.e. it's
associated to collections (key, collection of values). It's immutable.
- Author:
- Fabrizio Giudici
-
Method Summary
Modifier and TypeMethodDescriptionMap<Key<?>, Collection<?>> asMap()Returns the contents as a plainMap.booleancontainsKey(Key<?> key) Checks whether a pair has been stored.Set<Map.Entry<Key<?>, Collection<?>>> entrySet()Returns a set of all the contained (key, value) pairs.voidforEach(BiConsumer<? super Key<?>, ? super Collection<?>> action) Performs the given action on all the pairs (key, value) contained in this map.<T> Collection<T> Returns a value given its key.keySet()Returns a set of all the contained keys.static TypeSafeMultiMapCreates a new empty instance.static TypeSafeMultiMapofCloned(Map<? extends Key<?>, ? extends Collection<?>> map) Creates an instance cloning the given map.intsize()Returns the size of this map.Collection<Collection<?>> values()Returns a set of all the contained values.<T> TypeSafeMultiMapCreates a new instance with an additional pair (key, value).Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
get
Returns a value given its key.- Type Parameters:
T- the type- Parameters:
key- the key- Returns:
- the value as a
Collection
-
containsKey
Checks whether a pair has been stored.- Parameters:
key- the key- Returns:
trueif the pair is present
-
keySet
Returns a set of all the contained keys.- Returns:
- the keys as a mutable set
-
values
Returns a set of all the contained values.- Returns:
- the values as a mutable collection
- Since:
- 3.2-ALPHA-6
-
entrySet
Returns a set of all the contained (key, value) pairs.- Returns:
- the pairs as a mutable collection
- Since:
- 3.2-ALPHA-6
-
size
@Nonnegative int size()Returns the size of this map.- Returns:
- the size
-
forEach
Performs the given action on all the pairs (key, value) contained in this map.- Parameters:
action- the action- Since:
- 3.2-ALPHA-10
-
asMap
Returns the contents as a plainMap.- Returns:
- the contents as a mutable map
-
with
Creates a new instance with an additional pair (key, value).- Type Parameters:
T- the type- Parameters:
key- the keyvalue- the value- Returns:
- the new instance
- Since:
- 3.2-ALPHA-2
-
ofCloned
@Nonnull static TypeSafeMultiMap ofCloned(@Nonnull Map<? extends Key<?>, ? extends Collection<?>> map) Creates an instance cloning the given map.- Parameters:
map- the map to clone- Returns:
- the new instance
- Since:
- 3.2-ALPHA-2
-
newInstance
Creates a new empty instance.- Returns:
- the new instance
- Since:
- 3.2-ALPHA-2
-