Module io.netty5.common
Package io.netty5.util

Interface Attribute<T>

  • Type Parameters:
    T - the type of the value it holds.

    public interface Attribute<T>
    An attribute which allows to store a value reference. It may be updated atomically and so is thread-safe.
    • Method Summary

      All Methods
      Modifier and Type Method Description
      boolean compareAndSet ​(T oldValue, T newValue)
      Atomically sets the value to the given updated value if the current value == the expected value.
      T get ()
      Returns the current value, which may be null
      T getAndRemove ()
      Deprecated.
      please consider using getAndSet(Object) (with value of null).
      T getAndSet ​(T value)
      Atomically sets to the given value and returns the old value which may be null if non was set before.
      AttributeKey<T> key ()
      Returns the key of this attribute.
      void remove ()
      Deprecated.
      please consider using set(Object) (with value of null).
      void set ​(T value)
      Sets the value
      T setIfAbsent ​(T value)
      Atomically sets to the given value if this Attribute's value is null.
    • Method Detail

      • get

        T get()
        Returns the current value, which may be null
      • set

        void set​(T value)
        Sets the value
      • getAndSet

        T getAndSet​(T value)
        Atomically sets to the given value and returns the old value which may be null if non was set before.
      • setIfAbsent

        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.
      • compareAndSet

        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.