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
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 withSupplier.get()
and will returnnull
if unassigned, and may be assigned withset(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
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default void
accept(V value)
default <C> ChainableAssignment<V,C>
chainableWith(C chainReturnObject)
Create aChainableAssignment
from this assignment.static <V> Assignment<V>
from(AtomicReference<V> reference)
Create a newAssignment
which uses anAtomicReference
to 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.void
set(V value)
Assign the given value.-
Methods inherited from interface no.digipost.util.ViewableAsOptional.Single
toOptional
-
-
-
-
Method Detail
-
from
static <V> Assignment<V> from(AtomicReference<V> reference)
Create a newAssignment
which uses anAtomicReference
to hold the assigned value.- Parameters:
reference
- the holder of the assigned value- Returns:
- the new
Assignment
using 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
void set(V value)
Assign the given value.- Parameters:
value
- the value to assign.
-
chainableWith
default <C> ChainableAssignment<V,C> chainableWith(C chainReturnObject)
Create aChainableAssignment
from this assignment.- See Also:
ChainableAssignment
-
-