Class AttributesMap

  • All Implemented Interfaces:
    Attributes, java.io.Serializable, java.lang.Cloneable, java.util.Map<AttributeKey<?>,​java.lang.Object>

    public final class AttributesMap
    extends java.util.HashMap<AttributeKey<?>,​java.lang.Object>
    implements Attributes
    A map with a fixed capacity that drops attributes when the map gets full, and which truncates string and array string attribute values to the lengthLimit.

    This class is internal and is hence not for public use. Its APIs are unstable and can change at any time.

    See Also:
    Serialized Form
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.util.AbstractMap

        java.util.AbstractMap.SimpleEntry<K extends java.lang.Object,​V extends java.lang.Object>, java.util.AbstractMap.SimpleImmutableEntry<K extends java.lang.Object,​V extends java.lang.Object>
      • Nested classes/interfaces inherited from interface java.util.Map

        java.util.Map.Entry<K extends java.lang.Object,​V extends java.lang.Object>
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private AttributesMap​(long capacity, int lengthLimit)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Map<AttributeKey<?>,​java.lang.Object> asMap()
      Returns a read-only view of this Attributes as a Map.
      static AttributesMap create​(long capacity, int lengthLimit)
      Create an instance.
      void forEach​(java.util.function.BiConsumer<? super AttributeKey<?>,​? super java.lang.Object> action)
      Iterates over all the key-value pairs of attributes contained by this instance.
      <T> T get​(AttributeKey<T> key)
      Returns the value for the given AttributeKey, or null if not found.
      int getTotalAddedValues()
      Get the total number of attributes added, including those dropped for capcity limits.
      Attributes immutableCopy()
      Create an immutable copy of the attributes in this map.
      <T> void put​(AttributeKey<T> key, T value)
      Add the attribute key value pair, applying capacity and length limits.
      AttributesBuilder toBuilder()
      Returns a new AttributesBuilder instance populated with the data of this Attributes.
      java.lang.String toString()  
      • Methods inherited from class java.util.HashMap

        clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
      • Methods inherited from class java.util.AbstractMap

        equals, hashCode
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Map

        equals, hashCode
    • Field Detail

      • capacity

        private final long capacity
      • lengthLimit

        private final int lengthLimit
      • totalAddedValues

        private int totalAddedValues
    • Constructor Detail

      • AttributesMap

        private AttributesMap​(long capacity,
                              int lengthLimit)
    • Method Detail

      • create

        public static AttributesMap create​(long capacity,
                                           int lengthLimit)
        Create an instance.
        Parameters:
        capacity - the max number of attribute entries
        lengthLimit - the maximum length of string attributes
      • put

        public <T> void put​(AttributeKey<T> key,
                            T value)
        Add the attribute key value pair, applying capacity and length limits.
      • getTotalAddedValues

        public int getTotalAddedValues()
        Get the total number of attributes added, including those dropped for capcity limits.
      • forEach

        public void forEach​(java.util.function.BiConsumer<? super AttributeKey<?>,​? super java.lang.Object> action)
        Description copied from interface: Attributes
        Iterates over all the key-value pairs of attributes contained by this instance.
        Specified by:
        forEach in interface Attributes
        Specified by:
        forEach in interface java.util.Map<AttributeKey<?>,​java.lang.Object>
        Overrides:
        forEach in class java.util.HashMap<AttributeKey<?>,​java.lang.Object>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractMap<AttributeKey<?>,​java.lang.Object>
      • immutableCopy

        public Attributes immutableCopy()
        Create an immutable copy of the attributes in this map.