public final class Maps extends Object
| Modifier and Type | Method and Description |
|---|---|
static <K,V> Map<K,V> |
of(Object... pairs)
Will create map, give list of key, value pairs.
|
static <K,V> Map<K,V> |
of(Pair<K,V>... pairs)
Will create map, give list of key-value pairs.
|
static <K,V> Map<K,V> |
toMap(Iterable<V> list,
Func<K,V> keyGenerator)
Converts iterable to map using provided Key generator function.
|
static <K,V> Map<K,V> |
toUnmodifiableMap(Iterable<V> list,
Func<K,V> keyGenerator)
Converts iterable to map using provided Key generator function.
|
public static <K,V> Map<K,V> of(Object... pairs)
Will create map, give list of key, value pairs.
Example: Map<Integer, String> map = Maps.of(1, "One", 2, "Two", 3, "Three");
Number of parameters must be even. Will throw ClassCastException if wrong argument types are supplied
K - Type of keysV - Type of valuespairs - list of key-value pairs. There is no special separation of each pair.public static <K,V> Map<K,V> of(Pair<K,V>... pairs)
Will create map, give list of key-value pairs.
Pairs are represented by Pair objects where left is used as key and right is used for value.
K - Type of keysV - Type of valuespairs - list of key-value pairs.public static <K,V> Map<K,V> toMap(Iterable<V> list, Func<K,V> keyGenerator)
K - Type of map key.V - Type of iterable valueslist - - Iterable to convert into MapkeyGenerator - Key generator function.public static <K,V> Map<K,V> toUnmodifiableMap(Iterable<V> list, Func<K,V> keyGenerator)
Generated Map will be unmodifiable.
K - Type of map key.V - Type of iterable valueslist - - Iterable to convert into MapkeyGenerator - Key generator function.Copyright © 2018. All rights reserved.