K - The type of keys maintained by the resulting mapV - The type of mapped valuespublic static final class MoreCollections.MapBuilder<K,V>
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
java.util.Map<K,V> |
build()
Creates a new map from the specified values
|
java.util.Map<K,V> |
build(java.util.function.Supplier<java.util.Map<K,V>> mapSupplier)
Creates a new map from the specified values
|
MoreCollections.MapBuilder<K,V> |
mutable()
Configures the resulting map to be mutable/modifiable
|
MoreCollections.MapBuilder<K,V> |
put(K key,
V value) |
MoreCollections.MapBuilder<K,V> |
putAll(java.util.Map<? extends K,? extends V> m) |
public MoreCollections.MapBuilder<K,V> put(K key, V value)
key - Key to add to the result of this buildervalue - Values to associate with the resulting keypublic MoreCollections.MapBuilder<K,V> putAll(java.util.Map<? extends K,? extends V> m)
m - Existing map of values to add to the result of this builderpublic MoreCollections.MapBuilder<K,V> mutable()
public java.util.Map<K,V> build()
Map<String, String> example = MoreCollections.<String, String> mapBuilder()
.put("key", "value")
.build();
public java.util.Map<K,V> build(java.util.function.Supplier<java.util.Map<K,V>> mapSupplier)
Provided for cases where the specific implementation, capacity, or other properties of the resulting map are important. Note that unless mutabliity is specified, the resulting map will be made unmodifiable
Map<String, String> example = MoreCollections.<String, String> mapBuilder()
.put("key", "value")
.build(LinkedHashMap::new);
mapSupplier - Supplier which provides a map with specific required properties for use