Class DefaultAttributeMap.DefaultAttribute<T>
- All Implemented Interfaces:
Attribute<T>
,Serializable
- Enclosing class:
DefaultAttributeMap
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DefaultAttributeMap
private final AttributeKey
<T> private static final AtomicReferenceFieldUpdater
<DefaultAttributeMap.DefaultAttribute, DefaultAttributeMap> private static final long
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRemoves this attribute from theAttributeMap
and returns the old value.private boolean
key()
Returns the key of this attribute.void
remove()
Removes this attribute from theAttributeMap
.setIfAbsent
(T value) Atomically sets to the given value if thisAttribute
's value isnull
.Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface io.netty.util.Attribute
compareAndSet, get, getAndSet, set
-
Field Details
-
MAP_UPDATER
private static final AtomicReferenceFieldUpdater<DefaultAttributeMap.DefaultAttribute,DefaultAttributeMap> MAP_UPDATER -
serialVersionUID
private static final long serialVersionUID- See Also:
-
attributeMap
-
key
-
-
Constructor Details
-
DefaultAttribute
DefaultAttribute(DefaultAttributeMap attributeMap, AttributeKey<T> key)
-
-
Method Details
-
key
Description copied from interface:Attribute
Returns the key of this attribute. -
isRemoved
private boolean isRemoved() -
setIfAbsent
Description copied from interface:Attribute
Atomically sets to the given value if thisAttribute
's value isnull
. If it was not possible to set the value as it contains a value it will just return the current value.- Specified by:
setIfAbsent
in interfaceAttribute<T>
-
getAndRemove
Description copied from interface:Attribute
Removes this attribute from theAttributeMap
and returns the old value. SubsequentAttribute.get()
calls will returnnull
. If you only want to return the old value and clear theAttribute
while still keep it in theAttributeMap
useAttribute.getAndSet(Object)
with a value ofnull
.Be aware that even if you call this method another thread that has obtained a reference to this
Attribute
viaAttributeMap.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 newAttribute
instance 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 callAttribute.remove()
orAttribute.getAndRemove()
.- Specified by:
getAndRemove
in interfaceAttribute<T>
-
remove
public void remove()Description copied from interface:Attribute
Removes this attribute from theAttributeMap
. SubsequentAttribute.get()
calls will return @{code null}. If you only want to remove the value and clear theAttribute
while still keep it inAttributeMap
useAttribute.set(Object)
with a value ofnull
.Be aware that even if you call this method another thread that has obtained a reference to this
Attribute
viaAttributeMap.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 newAttribute
instance 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 callAttribute.remove()
orAttribute.getAndRemove()
.
-