Interface ReferenceWrapper<T>

Type Parameters:
T - type of reference
All Known Implementing Classes:
ReferenceWrapper.AtomicReferenceWrapper, ReferenceWrapper.PrimitiveReferenceWrapper

public interface ReferenceWrapper<T>
Wrapper of a reference.
  • Method Details

    • create

      static <T> ReferenceWrapper<T> create(T value)
      Creates new simple reference wrapper.
      Type Parameters:
      T - type of reference
      Parameters:
      value - initial reference of int wrapper
      Returns:
      created reference wrapper
    • create

      static <T> ReferenceWrapper<T> create()
      Creates new simple reference wrapper with initial value set to null.
      Type Parameters:
      T - type of reference
      Returns:
      created reference wrapper
    • createAtomic

      static <T> ReferenceWrapper<T> createAtomic(T value)
      Creates new atomic reference wrapper.
      Type Parameters:
      T - type of reference
      Parameters:
      value - initial value of reference wrapper
      Returns:
      created reference wrapper
    • createAtomic

      static <T> ReferenceWrapper<T> createAtomic()
      Creates new atomic reference wrapper with initial value set to null.
      Type Parameters:
      T - type of reference
      Returns:
      created reference wrapper
    • get

      T get()
      Gets the value.
      Returns:
      value
    • set

      void set(T newValue)
      Sets the value.
      Parameters:
      newValue - value to be set
    • getAndSet

      T getAndSet(T newValue)
      Sets the value to the one given returning the previous one.
      Parameters:
      newValue - value to be set
      Returns:
      previous value
    • getAndUpdate

      T getAndUpdate(@NonNull @NonNull UnaryOperator<T> updateFunction)
      Updates the current value using the specified function after what the new value is returned.
      Parameters:
      updateFunction - function to be used for updating the value
      Returns:
      value before update
    • updateAndGet

      T updateAndGet(@NonNull @NonNull UnaryOperator<T> updateFunction)
      Gets the value after what it gets updated using the specified function.
      Parameters:
      updateFunction - function to be used for updating the value
      Returns:
      value after update
    • getAndAccumulate

      T getAndAccumulate(T updateValue, @NonNull @NonNull BinaryOperator<T> accumulatorFunction)
      Updates the current value using specified function and update value after what the new value is returned.
      Parameters:
      updateValue - update value (will be passed as the second function parameter)
      accumulatorFunction - function to be used for updating the value
      Returns:
      value before update
    • accumulateAndGet

      T accumulateAndGet(T updateValue, @NonNull @NonNull BinaryOperator<T> accumulatorFunction)
      Gets the value after what it gets updated using the specified function and update value.
      Parameters:
      updateValue - update value (will be passed as the second function parameter)
      accumulatorFunction - function to be used for updating the value
      Returns:
      value after update