Class AttributesMap
- All Implemented Interfaces:
Attributes, Serializable, Cloneable, Map<AttributeKey<?>, Object>
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class AbstractMap
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K, V> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final longprivate final intprivate static final longprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionMap<AttributeKey<?>, Object> asMap()Returns a read-only view of thisAttributesas aMap.static AttributesMapcreate(long capacity, int lengthLimit) Create an instance.voidforEach(BiConsumer<? super AttributeKey<?>, ? super Object> action) Iterates over all the key-value pairs of attributes contained by this instance.<T> Tget(AttributeKey<T> key) Returns the value for the givenAttributeKey, ornullif not found.intGet the total number of attributes added, including those dropped for capcity limits.Create an immutable copy of the attributes in this map.<T> voidput(AttributeKey<T> key, T value) Add the attribute key value pair, applying capacity and length limits.Returns a newAttributesBuilderinstance populated with the data of thisAttributes.toString()Methods inherited from class HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, get, getOrDefault, isEmpty, keySet, merge, newHashMap, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesMethods inherited from class AbstractMap
equals, hashCodeMethods inherited from interface Attributes
isEmpty, size
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
capacity
private final long capacity -
lengthLimit
private final int lengthLimit -
totalAddedValues
private int totalAddedValues
-
-
Constructor Details
-
AttributesMap
private AttributesMap(long capacity, int lengthLimit)
-
-
Method Details
-
create
Create an instance.- Parameters:
capacity- the max number of attribute entrieslengthLimit- the maximum length of string attributes
-
put
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. -
get
Description copied from interface:AttributesReturns the value for the givenAttributeKey, ornullif not found.- Specified by:
getin interfaceAttributes
-
asMap
Description copied from interface:AttributesReturns a read-only view of thisAttributesas aMap.- Specified by:
asMapin interfaceAttributes
-
toBuilder
Description copied from interface:AttributesReturns a newAttributesBuilderinstance populated with the data of thisAttributes.- Specified by:
toBuilderin interfaceAttributes
-
forEach
Description copied from interface:AttributesIterates over all the key-value pairs of attributes contained by this instance.- Specified by:
forEachin interfaceAttributes- Specified by:
forEachin interfaceMap<AttributeKey<?>, Object>- Overrides:
forEachin classHashMap<AttributeKey<?>, Object>
-
toString
- Overrides:
toStringin classAbstractMap<AttributeKey<?>, Object>
-
immutableCopy
Create an immutable copy of the attributes in this map.
-