Class MapFieldLite<K,​V>

  • All Implemented Interfaces:
    Serializable, Cloneable, Map<K,​V>

    public final class MapFieldLite<K,​V>
    extends HashMap<K,​V>
    Internal representation of map fields in generated lite-runtime messages.

    This class is a protobuf implementation detail. Users shouldn't use this class directly.

    See Also:
    Serialized Form
    • Method Detail

      • emptyMapField

        public static <K,​V> MapFieldLite<K,​V> emptyMapField()
        Returns a singleton immutable empty MapFieldLite instance.
      • entrySet

        public Set<Map.Entry<K,​V>> entrySet()
        Description copied from class: HashMap
        Returns a Set view 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 own remove operation, or through the setValue operation 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 the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
        Specified by:
        entrySet in interface Map<K,​V>
        Overrides:
        entrySet in class HashMap<K,​V>
        Returns:
        a set view of the mappings contained in this map
      • clear

        public void clear()
        Description copied from class: HashMap
        Removes all of the mappings from this map. The map will be empty after this call returns.
        Specified by:
        clear in interface Map<K,​V>
        Overrides:
        clear in class HashMap<K,​V>
      • put

        @CanIgnoreReturnValue
        public V put​(K key,
                     V value)
        Description copied from class: HashMap
        Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.
        Specified by:
        put in interface Map<K,​V>
        Overrides:
        put in class HashMap<K,​V>
        Parameters:
        key - key with which the specified value is to be associated
        value - value to be associated with the specified key
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)
      • put

        @CanIgnoreReturnValue
        public V put​(Map.Entry<K,​V> entry)
      • putAll

        public void putAll​(Map<? extends K,​? extends V> m)
        Description copied from class: HashMap
        Copies all of the mappings from the specified map to this map. These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
        Specified by:
        putAll in interface Map<K,​V>
        Overrides:
        putAll in class HashMap<K,​V>
        Parameters:
        m - mappings to be stored in this map
      • remove

        @CanIgnoreReturnValue
        public V remove​(Object key)
        Description copied from class: HashMap
        Removes the mapping for the specified key from this map if present.
        Specified by:
        remove in interface Map<K,​V>
        Overrides:
        remove in class HashMap<K,​V>
        Parameters:
        key - key whose mapping is to be removed from the map
        Returns:
        the previous value associated with key, or null if there was no mapping for key. (A null return can also indicate that the map previously associated null with key.)
      • equals

        public boolean equals​(Object object)
        Checks whether two map fields are equal.
        Specified by:
        equals in interface Map<K,​V>
        Overrides:
        equals in class AbstractMap<K,​V>
        Parameters:
        object - object to be compared for equality with this map
        Returns:
        true if the specified object is equal to this map
        See Also:
        Object.hashCode(), HashMap
      • hashCode

        public int hashCode()
        Description copied from class: AbstractMap
        Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object.hashCode().

        This implementation iterates over entrySet(), calling hashCode() on each element (entry) in the set, and adding up the results.

        Specified by:
        hashCode in interface Map<K,​V>
        Overrides:
        hashCode in class AbstractMap<K,​V>
        Returns:
        the hash code value for this map
        See Also:
        Map.Entry.hashCode(), Object.equals(Object), Set.equals(Object)
      • mutableCopy

        public MapFieldLite<K,​V> mutableCopy()
        Returns a deep copy of this map field.
      • makeImmutable

        public void makeImmutable()
        Makes this field immutable. All subsequent modifications will throw an UnsupportedOperationException.
      • isMutable

        public boolean isMutable()
        Returns whether this field can be modified.