Interface Attribute<T>
- Type Parameters:
T- the type of the value it holds.
-
Method Summary
Modifier and TypeMethodDescriptionbooleancompareAndSet(T oldValue, T newValue) Atomically sets the value to the given updated value if the current value == the expected value.get()Returns the current value, which may benullDeprecated.Atomically sets to the given value and returns the old value which may benullif non was set before.key()Returns the key of this attribute.voidremove()Deprecated.please consider usingset(Object)(with value ofnull).voidSets the valuesetIfAbsent(T value) Atomically sets to the given value if thisAttribute's value isnull.
-
Method Details
-
key
AttributeKey<T> key()Returns the key of this attribute. -
get
T get()Returns the current value, which may benull -
set
Sets the value -
getAndSet
-
setIfAbsent
-
getAndRemove
Deprecated.please consider usinggetAndSet(Object)(with value ofnull).Removes this attribute from theAttributeMapand returns the old value. Subsequentget()calls will returnnull. If you only want to return the old value and clear theAttributewhile still keep it in theAttributeMapusegetAndSet(Object)with a value ofnull.Be aware that even if you call this method another thread that has obtained a reference to this
AttributeviaAttributeMap.attr(AttributeKey)will still operate on the same instance. That said if now another thread or even the same thread later will callAttributeMap.attr(AttributeKey)again, a newAttributeinstance is created and so is not the same as the previous one that was removed. Because of this special caution should be taken when you callremove()orgetAndRemove(). -
compareAndSet
-
remove
Deprecated.please consider usingset(Object)(with value ofnull).Removes this attribute from theAttributeMap. Subsequentget()calls will return @{code null}. If you only want to remove the value and clear theAttributewhile still keep it inAttributeMapuseset(Object)with a value ofnull.Be aware that even if you call this method another thread that has obtained a reference to this
AttributeviaAttributeMap.attr(AttributeKey)will still operate on the same instance. That said if now another thread or even the same thread later will callAttributeMap.attr(AttributeKey)again, a newAttributeinstance is created and so is not the same as the previous one that was removed. Because of this special caution should be taken when you callremove()orgetAndRemove().
-
getAndSet(Object)(with value ofnull).