Serializable, Cloneable, Iterable<K>, Map<K,V>, InternalIterable<K>, MapIterable<K,V>, MutableMap<K,V>, MutableMapIterable<K,V>, UnsortedMapIterable<K,V>, RichIterable<K>public class MapAdapter<K,V> extends AbstractMutableMap<K,V> implements Serializable
To create a new wrapper around an existing Map instance, use the adapt(Map) factory method.
| Modifier and Type | Method | Description |
|---|---|---|
static <K,V> MutableMap<K,V> |
adapt(Map<K,V> map) |
|
void |
clear() |
|
MutableMap<K,V> |
clone() |
|
<E> MutableMap<K,V> |
collectKeysAndValues(Iterable<E> iterable,
Function<? super E,? extends K> keyFunction,
Function<? super E,? extends V> valueFunction) |
Adds all the entries derived from
iterable to this. |
boolean |
containsKey(Object key) |
|
boolean |
containsValue(Object value) |
|
Set<Map.Entry<K,V>> |
entrySet() |
|
boolean |
equals(Object o) |
Follows the same general contract as
Map.equals(Object). |
void |
forEachKeyValue(Procedure2<? super K,? super V> procedure) |
Calls the
procedure with each key-value pair of the map. |
V |
get(Object key) |
|
int |
hashCode() |
Follows the same general contract as
Map.hashCode(). |
boolean |
isEmpty() |
Returns true if this iterable has zero items.
|
Iterator<V> |
iterator() |
|
Set<K> |
keySet() |
|
MutableMap<K,V> |
newEmpty() |
Creates a new instance of the same type, using the default capacity and growth parameters.
|
<K,V> MutableMap<K,V> |
newEmpty(int capacity) |
Creates a new instance of the same type, using the given capacity and the default growth parameters.
|
V |
put(K key,
V value) |
|
void |
putAll(Map<? extends K,? extends V> map) |
|
V |
remove(Object key) |
|
boolean |
removeIf(Predicate2<? super K,? super V> predicate) |
Remove an entry from the map if the
predicate evaluates to true. |
V |
removeKey(K key) |
Remove an entry from the map at the specified
key. |
int |
size() |
Returns the number of items in this iterable.
|
ImmutableMap<K,V> |
toImmutable() |
Returns an immutable copy of this map.
|
String |
toString() |
Returns a string with the elements of the iterable separated by commas with spaces and
enclosed in square brackets.
|
Collection<V> |
values() |
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, ifPresentApply, noneSatisfy, noneSatisfyWith, toArray, toArrayasSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, select, select, selectInstancesOf, selectWith, tap, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexaggregateBy, aggregateInPlaceBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, keysView, keyValuesView, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWith, valuesViewappendString, appendString, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, containsAll, containsAllArguments, containsAllIterable, count, countWith, flatCollect, forEach, groupBy, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, max, max, maxBy, min, min, minBy, reject, rejectWith, select, selectWith, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toBag, toBiMap, toList, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexforEach, forEachWith, forEachWithIndexcompute, computeIfAbsent, computeIfPresent, entry, forEach, getOrDefault, merge, of, of, of, of, of, of, of, of, of, of, of, ofEntries, putIfAbsent, remove, replace, replace, replaceAlldetect, detectOptional, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewaggregateBy, aggregateInPlaceBy, collect, flatCollectWith, flipUniqueValuesadd, countBy, countByEach, countByWith, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, putPair, removeAllKeys, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWithallSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, into, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndexpublic static <K,V> MutableMap<K,V> adapt(Map<K,V> map)
public String toString()
AbstractRichIterable
Assert.assertEquals("[]", Lists.mutable.empty().toString());
Assert.assertEquals("[1]", Lists.mutable.with(1).toString());
Assert.assertEquals("[1, 2, 3]", Lists.mutable.with(1, 2, 3).toString());
toString in interface MapIterable<K,V>toString in interface RichIterable<K>toString in class AbstractRichIterable<V>AbstractCollection.toString()public MutableMap<K,V> clone()
clone in interface MutableMap<K,V>clone in class AbstractMutableMap<K,V>public <K,V> MutableMap<K,V> newEmpty(int capacity)
AbstractMutableMapnewEmpty in class AbstractMutableMap<K,V>public int size()
RichIterablepublic boolean isEmpty()
RichIterableisEmpty in interface Map<K,V>isEmpty in interface RichIterable<K>isEmpty in class AbstractRichIterable<V>public MutableMap<K,V> newEmpty()
MutableMapIterablenewEmpty in interface MutableMap<K,V>newEmpty in interface MutableMapIterable<K,V>public void forEachKeyValue(Procedure2<? super K,? super V> procedure)
MapIterableprocedure with each key-value pair of the map.
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");
forEachKeyValue in interface MapIterable<K,V>public V get(Object key)
get in interface Map<K,V>get in interface MapIterable<K,V>Map.get(Object)public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E,? extends K> keyFunction, Function<? super E,? extends V> valueFunction)
MutableMapiterable to this. The key and value for each entry
is determined by applying the keyFunction and valueFunction to each item in
collection. Any entry in map that has the same key as an entry in this
will have its value replaced by that in map.collectKeysAndValues in interface MutableMap<K,V>public V removeKey(K key)
MutableMapIterablekey.removeKey in interface MutableMapIterable<K,V>Map.remove(Object)public boolean removeIf(Predicate2<? super K,? super V> predicate)
MutableMapIterablepredicate evaluates to true.removeIf in interface MutableMapIterable<K,V>public boolean containsKey(Object key)
containsKey in interface Map<K,V>containsKey in interface MapIterable<K,V>Map.containsKey(Object)public boolean containsValue(Object value)
containsValue in interface Map<K,V>containsValue in interface MapIterable<K,V>Map.containsValue(Object)public boolean equals(Object o)
MapIterableMap.equals(Object).public int hashCode()
MapIterableMap.hashCode().public ImmutableMap<K,V> toImmutable()
MutableMapIterabletoImmutable in interface MapIterable<K,V>toImmutable in interface MutableMapIterable<K,V>toImmutable in interface UnsortedMapIterable<K,V>toImmutable in class AbstractMutableMap<K,V>Copyright © 2004–2019. All rights reserved.