public final class Maps extends Object
| Constructor and Description |
|---|
Maps() |
| Modifier and Type | Method and Description |
|---|---|
static <K,V> Map.Entry<K,V> |
entryOf(K key,
V value)
Get mutable entry
|
static <K,V> Map.Entry<K,V> |
immutableEntryOf(K key,
V value)
Get immutable entry
|
static <K,V> Map<K,V> |
of(Class<K> keyType,
Class<V> valueType,
Object... values)
Create map based on vararg parameter
|
static <K,V> Map<K,V> |
of(Object... values)
Create map based on vararg parameter
|
static <K,V> V |
put(Map<? super K,? super V> map,
K key,
V value)
Map.put(Object, Object) but returns the used value |
static <K,V> Map<V,K> |
swapped(Map<K,V> map,
Supplier<Map<V,K>> mapSupplier)
Swap keys with values
|
static <K,V> void |
update(Map<K,V> map,
K key,
Supplier<V> defaultValue,
Function<V,V> updateFunction)
Update value of map
|
public static <K,V> void update(Map<K,V> map, K key, Supplier<V> defaultValue, Function<V,V> updateFunction)
K - type of keyV - type of valuemap - the map to usekey - key of entry to updatedefaultValue - default value fetcherupdateFunction - function used to fetch updated valuepublic static <K,V> V put(Map<? super K,? super V> map, K key, V value)
Map.put(Object, Object) but returns the used valueK - type of keyV - type of valuemap - the map to put inkey - the keyvalue - the valuepublic static <K,V> Map<V,K> swapped(Map<K,V> map, Supplier<Map<V,K>> mapSupplier)
K - type of keyV - type of valuemap - the map to swapmapSupplier - the supplier to get new map instancepublic static <K,V> Map.Entry<K,V> entryOf(K key, V value)
K - type of keyV - type of valuekey - key of entryvalue - value of entrypublic static <K,V> Map.Entry<K,V> immutableEntryOf(K key, V value)
K - type of keyV - type of valuekey - key of entryvalue - value of entrypublic static <K,V> Map<K,V> of(Object... values)
K - type of keyV - type of valuevalues - valuespublic static <K,V> Map<K,V> of(Class<K> keyType, Class<V> valueType, Object... values)
K - type of keyV - type of valuevalues - valueskeyType - the class to define type of keyvalueType - the class to define type of valueCopyright © 2020. All rights reserved.