Top Description Methods
io.netty.util

public Interface Attribute<T>

Known Direct Implementers
io.netty.util.DefaultAttributeMap.DefaultAttribute
Type Parameters
<T>
the type of the value it holds.

An attribute which allows to store a value reference. It may be updated atomically and so is thread-safe.

Method Summary

Modifier and TypeMethod and Description
public boolean
compareAndSet(T oldValue, T newValue)

Atomically sets the value to the given updated value if the current value == the expected value.

public T
get()

Returns the current value, which may be null

public T
getAndRemove()

Deprecated please consider using getAndSet(Object) (with value of null).
Removes this attribute from the AttributeMap and returns the old value.
public T
getAndSet(T value)

Atomically sets to the given value and returns the old value which may be null if non was set before.

public AttributeKey<T>
key()

Returns the key of this attribute.

public void
remove()

Deprecated please consider using set(Object) (with value of null).
Removes this attribute from the AttributeMap.
public void
set(T value)

Sets the value

public T
setIfAbsent(T value)

Atomically sets to the given value if this Attribute's value is null.

Method Detail

compareAndSetback to summary
public boolean compareAndSet(T oldValue, T newValue)

Atomically sets the value to the given updated value if the current value == the expected value. If it the set was successful it returns true otherwise false.

getback to summary
public T get()

Returns the current value, which may be null

getAndRemoveback to summary
public T getAndRemove()

Deprecated

please consider using getAndSet(Object) (with value of null).

Removes this attribute from the AttributeMap and returns the old value. Subsequent get() calls will return null. If you only want to return the old value and clear the Attribute while still keep it in the AttributeMap use getAndSet(Object) with a value of null.

Be aware that even if you call this method another thread that has obtained a reference to this Attribute via AttributeMap#attr(AttributeKey) will still operate on the same instance. That said if now another thread or even the same thread later will call AttributeMap#attr(AttributeKey) again, a new Attribute 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 call remove() or getAndRemove().

Annotations
@Deprecated
getAndSetback to summary
public T getAndSet(T value)

Atomically sets to the given value and returns the old value which may be null if non was set before.

keyback to summary
public AttributeKey<T> key()

Returns the key of this attribute.

removeback to summary
public void remove()

Deprecated

please consider using set(Object) (with value of null).

Removes this attribute from the AttributeMap. Subsequent get() calls will return @{code null}. If you only want to remove the value and clear the Attribute while still keep it in AttributeMap use set(Object) with a value of null.

Be aware that even if you call this method another thread that has obtained a reference to this Attribute via AttributeMap#attr(AttributeKey) will still operate on the same instance. That said if now another thread or even the same thread later will call AttributeMap#attr(AttributeKey) again, a new Attribute 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 call remove() or getAndRemove().

Annotations
@Deprecated
setback to summary
public void set(T value)

Sets the value

setIfAbsentback to summary
public T setIfAbsent(T value)

Atomically sets to the given value if this Attribute's value is null. If it was not possible to set the value as it contains a value it will just return the current value.