public final class Maps
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Maps.MapBuilder<K,V>
A builder class for maps.
|
Modifier and Type | Method and Description |
---|---|
static <K,V> Maps.MapBuilder<K,V> |
builder()
Creates a new map builder.
|
static <K,V,X extends java.lang.Throwable> |
computeIfAbsent(java.util.Map<K,V> map,
K key,
ThrowingFunction<? super K,? extends V,? extends X> function)
An unsafe version of
Map.computeIfAbsent that may throw a checked
exception. |
static <K,T> T |
get(java.util.Map<? super K,?> map,
K key)
Gets the element mapped to
K in a map, casting it as needed. |
public static <K,V> Maps.MapBuilder<K,V> builder()
K
- the type of the keys in the final mapV
- the type of the values in the final mappublic static <K,V,X extends java.lang.Throwable> V computeIfAbsent(java.util.Map<K,V> map, K key, ThrowingFunction<? super K,? extends V,? extends X> function) throws X extends java.lang.Throwable
Map.computeIfAbsent
that may throw a checked
exception.K
- the type of keys in the mapV
- the type of values in the mapX
- the type of exception that the compute function may throwmap
- the map to modifykey
- the key to getfunction
- the compute functionX
- if the compute function threw an exceptionX extends java.lang.Throwable
public static <K,T> T get(java.util.Map<? super K,?> map, K key) throws java.util.NoSuchElementException
K
in a map, casting it as needed.K
- the type of keys in the mapT
- the type of the value to returnmap
- the map to get an element fromkey
- the key the element should be mapped tojava.util.NoSuchElementException
- if the key is not in the map