To create a new wrapper around an existing Map instance, use the adapt(Map) factory method.
| Modifier and Type | Field and Description |
|---|---|
| protected final Map | |
| private static final long |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public static <K, V> MutableMap | |
| public void | clear()
Implements java. Removes all of the mappings from this map (optional operation). |
| public MutableMap | clone()
Implements abstract org. Implements org. Creates and returns a copy of this object. |
| public <E> MutableMap | collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction)
Implements org. Adds all the entries derived from |
| public boolean | containsKey(Object key)
Implements org. Returns |
| public boolean | containsValue(Object value)
Implements org. Returns |
| public Set | entrySet()
Implements java. Returns a |
| public boolean | equals(Object o)
Overrides java. Implements org. Follows the same general contract as |
| public void | forEachKeyValue(Procedure2<? super K, ? super V> procedure)
Implements org. Calls the |
| public V | get(Object key)
Implements org. Returns the value to which the specified key is mapped,
or |
| public int | hashCode()
Overrides java. Implements org. Follows the same general contract as |
| public boolean | isEmpty()
Overrides org. Implements org. Returns |
| public Iterator | iterator()
Overrides org. Implements java. Returns an iterator over elements of type |
| public Set | |
| public V | merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction)
Overrides default java. If the specified key is not already associated with a value or is associated with null, associates it with the given non-null value (optional operation). |
| public <K, V> MutableMap | newEmpty(int capacity)
Implements abstract org. Creates a new instance of the same type, using the given capacity and the default growth parameters. |
| public MutableMap | newEmpty()
Implements org. Creates a new instance of the same type, using the default capacity and growth parameters. |
| public V | put(K key, V value)
Implements java. Associates the specified value with the specified key in this map (optional operation). |
| public void | putAll(Map<? extends K, ? extends V> map)
Implements java. Copies all of the mappings from the specified map to this map (optional operation). |
| public V | remove(Object key)
Implements java. Removes the mapping for a key from this map if it is present (optional operation). |
| public V | removeKey(K key)
Implements org. Remove an entry from the map at the specified |
| public int | size()
Implements org. Returns the number of key-value mappings in this map. |
| public ImmutableMap | toImmutable()
Overrides org. Implements org. Returns an immutable copy of this map. |
| public String | toString()
Overrides org. Implements org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. |
| public Collection | values()
Implements java. Returns a |
| delegate | back to summary |
|---|---|
| protected final Map<K, V> delegate | |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID | |
| MapAdapter | back to summary |
|---|---|
| protected MapAdapter(Map<K, V> newDelegate) | |
| adapt | back to summary |
|---|---|
| public static <K, V> MutableMap | |
| clear | back to summary |
|---|---|
| public void clear() Implements java. Doc from java. Removes all of the mappings from this map (optional operation). The map will be empty after this call returns.
| |
| clone | back to summary |
|---|---|
| public MutableMap Implements abstract org. Implements org. Doc from java. Creates and returns a copy of this object. The precise meaning
of "copy" may depend on the class of the object. The general
intent is that, for any object will be true, and that the expression:x.clone() != x will bex.clone().getClass() == x.getClass() true, but these are not absolute requirements.
While it is typically the case that:
will bex.clone().equals(x) true, this is not an absolute requirement.
By convention, the returned object should be obtained by calling
By convention, the object returned by this method should be independent
of this object (which is being cloned). To achieve this independence,
it may be necessary to modify one or more fields of the object returned
by
| |
| collectKeysAndValues | back to summary |
|---|---|
| public <E> MutableMap Implements org. Doc from org. Adds all the entries derived from
| |
| containsKey | back to summary |
|---|---|
| public boolean containsKey(Object key) Implements org. Doc from java. Returns
| |
| containsValue | back to summary |
|---|---|
| public boolean containsValue(Object value) Implements org. Doc from java. Returns
| |
| entrySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| equals | back to summary |
|---|---|
| public boolean equals(Object o) Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| forEachKeyValue | back to summary |
|---|---|
| public void forEachKeyValue(Procedure2<? super K, ? super V> procedure) Implements org. Doc from org. Calls the
final Collection<String> collection = new ArrayList<String>();
MutableMap<Integer, String> map = this.newMapWithKeysValues(1, "One", 2, "Two", 3, "Three");
map.forEachKeyValue((Integer key, String value) -> collection.add(String.valueOf(key) + value));
Verify.assertContainsAll(collection, "1One", "2Two", "3Three");
| |
| get | back to summary |
|---|---|
| public V get(Object key) Implements org. Doc from java. Returns the value to which the specified key is mapped,
or More formally, if this map contains a mapping from a key
If this map permits null values, then a return value of
| |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Implements org. Doc from org. Follows the same general contract as
| |
| isEmpty | back to summary |
|---|---|
| public boolean isEmpty() Overrides org. Implements org. Doc from java. Returns
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides org. Implements java. Doc from java. Returns an iterator over elements of type
| |
| keySet | back to summary |
|---|---|
| public Set Implements java. Doc from java. Returns a
| |
| merge | back to summary |
|---|---|
| public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) Overrides default java. Doc from java. If the specified key is not already associated with a value or is
associated with null, associates it with the given non-null value (optional
operation). Otherwise, replaces the associated value with the results of
the given remapping function, or removes if the result is
If the remapping function returns The remapping function should not modify this map during computation.
| |
| newEmpty | back to summary |
|---|---|
| public <K, V> MutableMap Implements abstract org. Doc from org. Creates a new instance of the same type, using the given capacity and the default growth parameters.
| |
| newEmpty | back to summary |
|---|---|
| public MutableMap Implements org. Doc from org. Creates a new instance of the same type, using the default capacity and growth parameters.
| |
| put | back to summary |
|---|---|
| public V put(K key, V value) Implements java. Doc from java. Associates the specified value with the specified key in this map
(optional operation). If the map previously contained a mapping for
the key, the old value is replaced by the specified value. (A map
| |
| putAll | back to summary |
|---|---|
| public void putAll(Map<? extends K, ? extends V> map) Implements java. Doc from java. Copies all of the mappings from the specified map to this map
(optional operation). The effect of this call is equivalent to that
of calling
| |
| remove | back to summary |
|---|---|
| public V remove(Object key) Implements java. Doc from java. Removes the mapping for a key from this map if it is present
(optional operation). More formally, if this map contains a mapping
from key Returns the value to which this map previously associated the key,
or If this map permits null values, then a return value of
The map will not contain a mapping for the specified key once the call returns.
| |
| removeKey | back to summary |
|---|---|
| public V removeKey(K key) Implements org. Doc from org. Remove an entry from the map at the specified
| |
| size | back to summary |
|---|---|
| public int size() Implements org. Doc from java. Returns the number of key-value mappings in this map. If the
map contains more than
| |
| toImmutable | back to summary |
|---|---|
| public ImmutableMap Overrides org. Implements org. Doc from org. Returns an immutable copy of this map. If the map is immutable, it returns itself.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Implements org. Doc from org. Returns a string with the keys and values of this map separated by commas with spaces and enclosed in curly braces. Each key and value is separated by an equals sign.
Assert.assertEquals("{1=1, 2=2, 3=3}", Maps.mutable.with(1, 1, 2, 2, 3, 3).toString());
| |
| values | back to summary |
|---|---|
| public Collection Implements java. Doc from java. Returns a
| |