Interface Assignment<V>

Type Parameters:
V - The type that may be assigned (or not).
All Superinterfaces:
Consumer<V>, Supplier<V>, ViewableAsOptional<V>, ViewableAsOptional.Single<V>
All Known Implementing Classes:
ChainableAssignment, OneTimeAssignment

public interface Assignment<V> extends Supplier<V>, Consumer<V>, ViewableAsOptional.Single<V>
An assignment may or may not be assigned, the assigned value can be retrieved with Supplier.get() and will return null if unassigned, and may be assigned with set(Object) if the assignment allows (re-)assignment.
  • Method Details

    • from

      static <V> Assignment<V> from(AtomicReference<V> reference)
      Create a new Assignment which uses an AtomicReference to hold the assigned value.
      Parameters:
      reference - the holder of the assigned value
      Returns:
      the new Assignment using the given AtomicReference.
    • from

      static <V, S> Assignment<V> from(S container, Function<? super S,V> getter, BiConsumer<? super S,? super V> setter)
      Create a new Assignment, which assigns to and retrieves from an arbitrary container object.
      Parameters:
      container - The holder of the assigned value.
      getter - how the get the value from the container
      setter - how to set the value on the container
      Returns:
      the get and set operations as a new Assignment.
    • set

      void set(V value)
      Assign the given value.
      Parameters:
      value - the value to assign.
    • accept

      default void accept(V value)
      Specified by:
      accept in interface Consumer<V>
    • chainableWith

      default <C> ChainableAssignment<V,C> chainableWith(C chainReturnObject)
      Create a ChainableAssignment from this assignment.
      See Also: