Class ValueHolder<T>

java.lang.Object
uk.ac.manchester.spinnaker.utils.ValueHolder<T>
Type Parameters:
T - The type of value to hold.

public class ValueHolder<T>
extends Object
A simple class that can optionally hold a single value. This class is modifiable.
Author:
Donal Fellows
  • Constructor Details

    • ValueHolder

      public ValueHolder()
      Create an instance. The initial value held is null.
    • ValueHolder

      public ValueHolder​(T value)
      Create an instance.
      Parameters:
      value - The initial value to hold.
  • Method Details

    • getValue

      public T getValue()
      Get the value held.
      Returns:
      The value held.
    • setValue

      public void setValue​(T value)
      Set the value to hold.
      Parameters:
      value - The new value to hold.
    • update

      public T update​(Function<T,​T> function)
      Applies a function to update the value of this instance, returning the old value.
      Parameters:
      function - The operation to apply.
      Returns:
      The old value.