Class DefaultAttributeMap.DefaultAttribute<T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<T>
-
- io.netty.util.DefaultAttributeMap.DefaultAttribute<T>
-
- All Implemented Interfaces:
Attribute<T>
,java.io.Serializable
- Enclosing class:
- DefaultAttributeMap
private static final class DefaultAttributeMap.DefaultAttribute<T> extends java.util.concurrent.atomic.AtomicReference<T> implements Attribute<T>
-
-
Field Summary
Fields Modifier and Type Field Description private DefaultAttributeMap.DefaultAttribute<?>
head
private AttributeKey<T>
key
private DefaultAttributeMap.DefaultAttribute<?>
next
private DefaultAttributeMap.DefaultAttribute<?>
prev
private boolean
removed
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description DefaultAttribute()
DefaultAttribute(DefaultAttributeMap.DefaultAttribute<?> head, AttributeKey<T> key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getAndRemove()
Removes this attribute from theAttributeMap
and returns the old value.AttributeKey<T>
key()
Returns the key of this attribute.void
remove()
Removes this attribute from theAttributeMap
.private void
remove0()
T
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 Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
head
private final DefaultAttributeMap.DefaultAttribute<?> head
-
key
private final AttributeKey<T> key
-
prev
private DefaultAttributeMap.DefaultAttribute<?> prev
-
next
private DefaultAttributeMap.DefaultAttribute<?> next
-
removed
private volatile boolean removed
-
-
Constructor Detail
-
DefaultAttribute
DefaultAttribute(DefaultAttributeMap.DefaultAttribute<?> head, AttributeKey<T> key)
-
DefaultAttribute
DefaultAttribute()
-
-
Method Detail
-
key
public AttributeKey<T> key()
Description copied from interface:Attribute
Returns the key of this attribute.
-
setIfAbsent
public T setIfAbsent(T value)
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
public 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()
.
-
remove0
private void remove0()
-
-