Package no.digipost.util
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
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.-
Nested Class Summary
Nested classes/interfaces inherited from interface no.digipost.util.ViewableAsOptional
ViewableAsOptional.Single<V>, ViewableAsOptional.TooManyElements -
Method Summary
Modifier and TypeMethodDescriptiondefault voiddefault <C> ChainableAssignment<V,C> chainableWith(C chainReturnObject) Create aChainableAssignmentfrom this assignment.static <V> Assignment<V>from(AtomicReference<V> reference) Create a newAssignmentwhich uses anAtomicReferenceto hold the assigned value.static <V,S> Assignment<V> from(S container, Function<? super S, V> getter, BiConsumer<? super S, ? super V> setter) Create a newAssignment, which assigns to and retrieves from an arbitrary container object.voidAssign the given value.Methods inherited from interface no.digipost.util.ViewableAsOptional.Single
toOptional
-
Method Details
-
from
Create a newAssignmentwhich uses anAtomicReferenceto hold the assigned value.- Parameters:
reference- the holder of the assigned value- Returns:
- the new
Assignmentusing the givenAtomicReference.
-
from
static <V,S> Assignment<V> from(S container, Function<? super S, V> getter, BiConsumer<? super S, ? super V> setter) Create a newAssignment, 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 containersetter- how to set the value on the container- Returns:
- the get and set operations as a new
Assignment.
-
set
Assign the given value.- Parameters:
value- the value to assign.
-
accept
-
chainableWith
Create aChainableAssignmentfrom this assignment.- See Also:
-