Class Internal.MapAdapter<K,V,RealValue>
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- com.google.protobuf.Internal.MapAdapter<K,V,RealValue>
-
- All Implemented Interfaces:
Map<K,V>
- Enclosing class:
- Internal
public static class Internal.MapAdapter<K,V,RealValue> extends AbstractMap<K,V>
Wrap around aMap<K, RealValue>and provide aMap<K, V>interface.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceInternal.MapAdapter.Converter<A,B>An interface used to convert between two types.-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
-
-
Constructor Summary
Constructors Constructor Description MapAdapter(Map<K,RealValue> realMap, Internal.MapAdapter.Converter<RealValue,V> valueConverter)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Set<Map.Entry<K,V>>entrySet()Returns aSetview of the mappings contained in this map.Vget(Object key)Returns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.static <T extends Internal.EnumLite>
Internal.MapAdapter.Converter<Integer,T>newEnumConverter(Internal.EnumLiteMap<T> enumMap, T unrecognizedValue)Vput(K key, V value)Associates the specified value with the specified key in this map (optional operation).-
Methods inherited from class java.util.AbstractMap
clear, clone, containsKey, containsValue, equals, hashCode, isEmpty, keySet, putAll, remove, size, toString, values
-
-
-
-
Method Detail
-
newEnumConverter
public static <T extends Internal.EnumLite> Internal.MapAdapter.Converter<Integer,T> newEnumConverter(Internal.EnumLiteMap<T> enumMap, T unrecognizedValue)
-
get
public V get(Object key)
Description copied from class:AbstractMapReturns the value to which the specified key is mapped, ornullif this map contains no mapping for the key.More formally, if this map contains a mapping from a key
kto a valuevsuch that(key==null ? k==null : key.equals(k)), then this method returnsv; otherwise it returnsnull. (There can be at most one such mapping.)If this map permits null values, then a return value of
nulldoes not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key tonull. ThecontainsKeyoperation may be used to distinguish these two cases.This implementation iterates over
entrySet()searching for an entry with the specified key. If such an entry is found, the entry's value is returned. If the iteration terminates without finding such an entry,nullis returned. Note that this implementation requires linear time in the size of the map; many implementations will override this method.
-
put
public V put(K key, V value)
Description copied from class:AbstractMapAssociates 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 mapmis said to contain a mapping for a keykif and only ifm.containsKey(k)would returntrue.)This implementation always throws an
UnsupportedOperationException.- Specified by:
putin interfaceMap<K,V>- Overrides:
putin classAbstractMap<K,V>- Parameters:
key- key with which the specified value is to be associatedvalue- value to be associated with the specified key- Returns:
- the previous value associated with
key, ornullif there was no mapping forkey. (Anullreturn can also indicate that the map previously associatednullwithkey, if the implementation supportsnullvalues.)
-
entrySet
public Set<Map.Entry<K,V>> entrySet()
Description copied from interface:MapReturns aSetview of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's ownremoveoperation, or through thesetValueoperation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via theIterator.remove,Set.remove,removeAll,retainAllandclearoperations. It does not support theaddoraddAlloperations.
-
-