Class DefaultAttributeMap.DefaultAttribute<T>
- All Implemented Interfaces:
Attribute<T>,Serializable
- Enclosing class:
DefaultAttributeMap
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DefaultAttributeMapprivate 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 theAttributeMapand returns the old value.private booleankey()Returns the key of this attribute.voidremove()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, weakCompareAndSetVolatileMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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:AttributeReturns the key of this attribute. -
isRemoved
private boolean isRemoved() -
setIfAbsent
Description copied from interface:AttributeAtomically 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:
setIfAbsentin interfaceAttribute<T>
-
getAndRemove
Description copied from interface:AttributeRemoves this attribute from theAttributeMapand returns the old value. SubsequentAttribute.get()calls will returnnull. If you only want to return the old value and clear theAttributewhile still keep it in theAttributeMapuseAttribute.getAndSet(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 callAttribute.remove()orAttribute.getAndRemove().- Specified by:
getAndRemovein interfaceAttribute<T>
-
remove
public void remove()Description copied from interface:AttributeRemoves this attribute from theAttributeMap. SubsequentAttribute.get()calls will return @{code null}. If you only want to remove the value and clear theAttributewhile still keep it inAttributeMapuseAttribute.set(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 callAttribute.remove()orAttribute.getAndRemove().
-