Package it.tidalwave.util
Interface TypeSafeMap
A map that is type safe, i.e. the pairs (key, value) are type-checked. It's immutable.
- Author:
- Fabrizio Giudici
-
Method Summary
Modifier and TypeMethodDescriptionasMap()Returns the contents as a plainMap.booleancontainsKey(Key<?> key) Checks whether a pair has been stored.entrySet()Returns a set of all the contained (key, value) pairs.<T> voidforEach(BiConsumer<? super Key<T>, ? super T> action) Performs the given action on all the pairs (key, value) contained in this map.<T> TDeprecated.default <T> Optional<T> getOptional(Key<? extends T> key) Returns an optional value given its key.keySet()Returns a set of all the contained keys.static TypeSafeMapCreates a new empty instance.static TypeSafeMapCreates an instance cloning the given map.intsize()Returns the size of this map.values()Returns a set of all the contained values.<T> TypeSafeMapCreate a new instance with an additional pair (key, value=Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
get
Deprecated.UsegetOptional(Key)insteadReturns a value given its key.- Type Parameters:
T- the type- Parameters:
key- the key- Returns:
- the value
- Throws:
NotFoundException- if the key is not found
-
getOptional
Returns an optional value given its key.- Type Parameters:
T- the type- Parameters:
key- the key- Returns:
- the value
- Since:
- 3.2-ALPHA-1
-
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
-
asMap
Returns the contents as a plainMap.- Returns:
- the contents as a mutable map
-
forEach
Performs the given action on all the pairs (key, value) contained in this map.- Type Parameters:
T- the value type- Parameters:
action- the action- Since:
- 3.2-ALPHA-10
-
with
Create 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
-
newInstance
Creates a new empty instance.- Returns:
- the new instance
- Since:
- 3.2-ALPHA-2
-
ofCloned
Creates an instance cloning the given map.- Parameters:
map- the map to clone- Returns:
- the new instance
- Since:
- 3.2-ALPHA-2
-
getOptional(Key)instead