Class MapFieldLite<K,V>

java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap<K,V>
java.util.LinkedHashMap<K,V>
com.google.protobuf.MapFieldLite<K,V>
All Implemented Interfaces:
Serializable, Cloneable, Map<K,V>, SequencedMap<K,V>

public final class MapFieldLite<K,V> extends LinkedHashMap<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:
  • Field Details

    • isMutable

      private boolean isMutable
    • EMPTY_MAP_FIELD

      private static final MapFieldLite<?,?> EMPTY_MAP_FIELD
  • Constructor Details

    • MapFieldLite

      private MapFieldLite()
    • MapFieldLite

      private MapFieldLite(Map<K,V> mapData)
  • Method Details

    • emptyMapField

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

      public void mergeFrom(MapFieldLite<K,V> other)
    • entrySet

      public Set<Map.Entry<K,V>> entrySet()
      Specified by:
      entrySet in interface Map<K,V>
      Overrides:
      entrySet in class LinkedHashMap<K,V>
    • clear

      public void clear()
      Specified by:
      clear in interface Map<K,V>
      Overrides:
      clear in class LinkedHashMap<K,V>
    • put

      public V put(K key, V value)
      Specified by:
      put in interface Map<K,V>
      Overrides:
      put in class HashMap<K,V>
    • put

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

      public void putAll(Map<? extends K,? extends V> m)
      Specified by:
      putAll in interface Map<K,V>
      Overrides:
      putAll in class HashMap<K,V>
    • remove

      public V remove(Object key)
      Specified by:
      remove in interface Map<K,V>
      Overrides:
      remove in class HashMap<K,V>
    • checkForNullKeysAndValues

      private static void checkForNullKeysAndValues(Map<?,?> m)
    • equals

      private static boolean equals(Object a, Object b)
    • equals

      static <K, V> boolean equals(Map<K,V> a, Map<K,V> b)
      Checks whether two Maps are equal. We don't use the default equals method of Map because it compares by identity not by content for byte arrays.
    • 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>
    • calculateHashCodeForObject

      private static int calculateHashCodeForObject(Object a)
    • calculateHashCodeForMap

      static <K, V> int calculateHashCodeForMap(Map<K,V> a)
      Calculates the hash code for a Map. We don't use the default hash code method of Map because for byte arrays and protobuf enums it use Object.hashCode().
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface Map<K,V>
      Overrides:
      hashCode in class AbstractMap<K,V>
    • copy

      private static Object copy(Object object)
    • copy

      static <K, V> Map<K,V> copy(Map<K,V> map)
      Makes a deep copy of a Map. Immutable objects in the map will be shared (e.g., integers, strings, immutable messages) and mutable ones will have a copy (e.g., byte arrays, mutable messages).
    • 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.
    • ensureMutable

      private void ensureMutable()