Class MapAdapter<K,V>
java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<V>
org.eclipse.collections.impl.map.AbstractMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMapIterable<K,V>
org.eclipse.collections.impl.map.mutable.AbstractMutableMap<K,V>
org.eclipse.collections.impl.map.mutable.MapAdapter<K,V>
- All Implemented Interfaces:
Serializable, Cloneable, Iterable<V>, Map<K,V>, InternalIterable<V>, MapIterable<K, V>, MutableMap<K, V>, MutableMapIterable<K, V>, UnsortedMapIterable<K, V>, RichIterable<V>
This class provides a MutableMap wrapper around a JDK Collections Map interface instance. All the MutableMap
interface methods are supported in addition to the JDK Map interface methods.
To create a new wrapper around an existing Map instance, use the adapt(Map) factory method.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMutableMap
AbstractMutableMap.ValuesCollectionCommon<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> MutableMap <K, V> voidclear()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 fromiterabletothis.booleancontainsKey(Object key) booleancontainsValue(Object value) entrySet()booleanFollows the same general contract asMap.equals(Object).voidforEachKeyValue(Procedure2<? super K, ? super V> procedure) Calls theprocedurewith each key-value pair of the map.inthashCode()Follows the same general contract asMap.hashCode().booleanisEmpty()Returns true if this iterable has zero items.iterator()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.voidRemove an entry from the map at the specifiedkey.intsize()Returns the number of items in this iterable.Returns an immutable copy of this map.toString()Returns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.values()Methods inherited from class AbstractMutableMap
asSynchronized, asUnmodifiable, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectKeysUnique, collectLong, collectShort, collectValues, collectWith, flatCollect, flip, groupBy, groupByEach, groupByUniqueKey, partition, partitionWith, reject, reject, rejectWith, replaceAll, select, select, selectInstancesOf, selectWith, tap, withAllKeyValueArguments, withAllKeyValues, withKeyValue, withoutAllKeys, withoutKey, zip, zipWithIndexMethods inherited from class AbstractMutableMapIterable
aggregateBy, collect, countBy, countByEach, countByWith, detect, detectOptional, flipUniqueValues, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, keysView, keyValuesView, reduceBy, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWith, valuesViewMethods inherited from class AbstractMapIterable
allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, asLazy, chunk, contains, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, forEachKey, forEachValue, forEachWith, forEachWithIndex, getFirst, getIfAbsent, getIfAbsentValue, getIfAbsentWith, getLast, getOnly, getOrDefault, ifPresentApply, isAbsent, keyAndValueEquals, keyAndValueHashCode, noneSatisfy, noneSatisfyWith, toArray, toArrayMethods inherited from class AbstractRichIterable
appendString, appendString, collect, collectIf, 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, zipWithIndexMethods inherited from interface InternalIterable
forEach, forEachWith, forEachWithIndexMethods inherited from interface Map
compute, computeIfAbsent, computeIfPresent, putIfAbsent, remove, replace, replaceMethods inherited from interface MapIterable
detect, detectOptional, forEachKey, forEachValue, getIfAbsent, getIfAbsentValue, getIfAbsentWith, ifPresentApply, injectIntoKeyValue, keysView, keyValuesView, parallelStream, spliterator, stream, valuesViewMethods inherited from interface MutableMap
aggregateBy, aggregateBy, aggregateInPlaceBy, collect, flatCollectWith, flipUniqueValues, reduceBy, withMap, withMapIterableMethods inherited from interface MutableMapIterable
add, countBy, countByEach, countByWith, forEach, getIfAbsentPut, getIfAbsentPut, getIfAbsentPutWith, getIfAbsentPutWithKey, getOrDefault, putAllMapIterable, putPair, removeAllKeys, removeIf, sumByDouble, sumByFloat, sumByInt, sumByLong, updateValue, updateValueWithMethods inherited from interface RichIterable
aggregateBy, allSatisfy, allSatisfyWith, anySatisfy, anySatisfyWith, appendString, appendString, appendString, asLazy, chunk, collect, collectBoolean, collectByte, collectChar, collectDouble, collectFloat, collectIf, collectInt, collectLong, collectShort, collectWith, contains, containsAll, containsAllArguments, containsAllIterable, containsAny, containsAnyIterable, containsBy, containsNone, containsNoneIterable, count, countBy, countByEach, countByWith, countWith, detect, detectIfNone, detectOptional, detectWith, detectWithIfNone, detectWithOptional, each, flatCollect, flatCollectBoolean, flatCollectByte, flatCollectChar, flatCollectDouble, flatCollectFloat, flatCollectInt, flatCollectLong, flatCollectShort, flatCollectWith, forEach, getAny, getFirst, getLast, getOnly, groupBy, groupByAndCollect, groupByEach, groupByUniqueKey, injectInto, injectInto, injectInto, injectInto, injectInto, injectIntoDouble, injectIntoFloat, injectIntoInt, injectIntoLong, into, makeString, makeString, makeString, makeString, max, max, maxBy, maxByOptional, maxOptional, maxOptional, min, min, minBy, minByOptional, minOptional, minOptional, noneSatisfy, noneSatisfyWith, notEmpty, reduce, reduceBy, reduceInPlace, reduceInPlace, reject, rejectWith, select, selectWith, summarizeDouble, summarizeFloat, summarizeInt, summarizeLong, sumOfDouble, sumOfFloat, sumOfInt, sumOfLong, toArray, toArray, toBag, toBiMap, toImmutableBag, toImmutableBiMap, toImmutableList, toImmutableMap, toImmutableSet, toImmutableSortedBag, toImmutableSortedBag, toImmutableSortedBagBy, toImmutableSortedList, toImmutableSortedList, toImmutableSortedListBy, toImmutableSortedSet, toImmutableSortedSet, toImmutableSortedSetBy, toList, toMap, toMap, toSet, toSortedBag, toSortedBag, toSortedBagBy, toSortedList, toSortedList, toSortedListBy, toSortedMap, toSortedMap, toSortedMapBy, toSortedSet, toSortedSet, toSortedSetBy, zip, zipWithIndex
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
delegate
-
-
Constructor Details
-
MapAdapter
-
-
Method Details
-
adapt
-
toString
Description copied from class:AbstractRichIterableReturns a string with the elements of the iterable separated by commas with spaces and enclosed in square brackets.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());- Specified by:
toStringin interfaceMapIterable<K,V> - Specified by:
toStringin interfaceRichIterable<K>- Overrides:
toStringin classAbstractRichIterable<V>- Returns:
- a string representation of this collection.
- See Also:
-
clone
- Specified by:
clonein interfaceMutableMap<K,V> - Specified by:
clonein classAbstractMutableMap<K,V>
-
newEmpty
Description copied from class:AbstractMutableMapCreates a new instance of the same type, using the given capacity and the default growth parameters.- Specified by:
newEmptyin classAbstractMutableMap<K,V>
-
size
public int size()Description copied from interface:RichIterableReturns the number of items in this iterable. -
isEmpty
public boolean isEmpty()Description copied from interface:RichIterableReturns true if this iterable has zero items.- Specified by:
isEmptyin interfaceMap<K,V> - Specified by:
isEmptyin interfaceRichIterable<K>- Overrides:
isEmptyin classAbstractRichIterable<V>
-
iterator
-
remove
-
keySet
-
values
-
entrySet
-
clear
-
newEmpty
Description copied from interface:MutableMapIterableCreates a new instance of the same type, using the default capacity and growth parameters.- Specified by:
newEmptyin interfaceMutableMap<K,V> - Specified by:
newEmptyin interfaceMutableMapIterable<K,V>
-
forEachKeyValue
Description copied from interface:MapIterableCalls theprocedurewith 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");- Specified by:
forEachKeyValuein interfaceMapIterable<K,V>
-
get
-
put
-
putAll
-
collectKeysAndValues
public <E> MutableMap<K,V> collectKeysAndValues(Iterable<E> iterable, Function<? super E, ? extends K> keyFunction, Function<? super E, ? extends V> valueFunction) Description copied from interface:MutableMapAdds all the entries derived fromiterabletothis. The key and value for each entry is determined by applying thekeyFunctionandvalueFunctionto each item incollection. Any entry inmapthat has the same key as an entry inthiswill have its value replaced by that inmap.- Specified by:
collectKeysAndValuesin interfaceMutableMap<K,V>
-
removeKey
Description copied from interface:MutableMapIterableRemove an entry from the map at the specifiedkey.- Specified by:
removeKeyin interfaceMutableMapIterable<K,V> - Returns:
- The value removed from entry at key, or null if not found.
- See Also:
-
containsKey
- Specified by:
containsKeyin interfaceMap<K,V> - Specified by:
containsKeyin interfaceMapIterable<K,V> - See Also:
-
containsValue
- Specified by:
containsValuein interfaceMap<K,V> - Specified by:
containsValuein interfaceMapIterable<K,V> - See Also:
-
merge
-
equals
Description copied from interface:MapIterableFollows the same general contract asMap.equals(Object). -
hashCode
public int hashCode()Description copied from interface:MapIterableFollows the same general contract asMap.hashCode(). -
toImmutable
Description copied from interface:MutableMapIterableReturns an immutable copy of this map. If the map is immutable, it returns itself.- Specified by:
toImmutablein interfaceMapIterable<K,V> - Specified by:
toImmutablein interfaceMutableMapIterable<K,V> - Specified by:
toImmutablein interfaceUnsortedMapIterable<K,V> - Overrides:
toImmutablein classAbstractMutableMap<K,V>
-