Class ReferenceWrapper.PrimitiveReferenceWrapper<T>

java.lang.Object
ru.progrm_jarvis.javacommons.primitive.wrapper.ReferenceWrapper.PrimitiveReferenceWrapper<T>
Type Parameters:
T - type of reference
All Implemented Interfaces:
ReferenceWrapper<T>
Enclosing interface:
ReferenceWrapper<T>

public static final class ReferenceWrapper.PrimitiveReferenceWrapper<T> extends Object implements ReferenceWrapper<T>
ReferenceWrapper implementation based on primitive reference.
  • Method Details

    • get

      public T get()
      Description copied from interface: ReferenceWrapper
      Gets the value.
      Specified by:
      get in interface ReferenceWrapper<T>
      Returns:
      value
    • set

      public void set(T newValue)
      Description copied from interface: ReferenceWrapper
      Sets the value.
      Specified by:
      set in interface ReferenceWrapper<T>
      Parameters:
      newValue - value to be set
    • getAndSet

      public T getAndSet(T newValue)
      Description copied from interface: ReferenceWrapper
      Sets the value to the one given returning the previous one.
      Specified by:
      getAndSet in interface ReferenceWrapper<T>
      Parameters:
      newValue - value to be set
      Returns:
      previous value
    • getAndUpdate

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

      public T updateAndGet(@NonNull @NonNull UnaryOperator<T> updateFunction)
      Description copied from interface: ReferenceWrapper
      Gets the value after what it gets updated using the specified function.
      Specified by:
      updateAndGet in interface ReferenceWrapper<T>
      Parameters:
      updateFunction - function to be used for updating the value
      Returns:
      value after update
    • getAndAccumulate

      public T getAndAccumulate(T updateValue, @NonNull @NonNull BinaryOperator<T> accumulatorFunction)
      Description copied from interface: ReferenceWrapper
      Updates the current value using specified function and update value after what the new value is returned.
      Specified by:
      getAndAccumulate in interface ReferenceWrapper<T>
      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

      public T accumulateAndGet(T updateValue, @NonNull @NonNull BinaryOperator<T> accumulatorFunction)
      Description copied from interface: ReferenceWrapper
      Gets the value after what it gets updated using the specified function and update value.
      Specified by:
      accumulateAndGet in interface ReferenceWrapper<T>
      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
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object