kiss
Variable
<V
>
V
>A re-assignable container object which may or may not contain a non-null value. If a value is
present, #isPresent()
returns true. If no value is present, the object is considered
empty and #isPresent()
returns false. Unlike Optional
, this container is
re-assignable.
Additional methods that depend on the presence or absence of a contained value are provided, such
as #or(Object)
(returns a default value if no value is present) and #to(Consumer)
(performs an action if a value is present).
v
V
The current value. This value is not final but read-only.
Variable
(V
value
)
V
value
)V value |
Hide constructor.
accept
(V
value
)
void
V
value
)V value |
acquire
()
V
V |
Current value or next value. |
Get the current value. If there is no value, wait until the value is set.
exact
()
V
V |
Current value or throws error. |
Get the current value. If there is no value, NullPointerException
will be thrown.
get
()
V
V |
Current value or null. |
Get the current value. If there is no value, returns null.
intercept
(WiseBiFunctionV
, V
, V
interceptor
)
VariableV
WiseBiFunctionV
, V
, V
interceptor
)V
WiseBiFunction interceptor |
An interceptor for value modification. First parameter is the current value, Second parameter is the new value. |
Variable |
Chainable API. |
Intercept the value modification.
is
(V
value
)
boolean
V
value
)V value |
A value to check the equality. |
boolean |
A result of equality. |
Test whether the current value is equal to the specified value or not.
is
(PredicateV
condition
)
boolean
PredicateV
condition
)Predicate condition |
A value validator. |
boolean |
A result of validation. |
Test whether the current value fulfills the specified condition or not.
isNot
(V
value
)
boolean
V
value
)V value |
A value to check the equality. |
boolean |
A result of equality. |
Test whether the current value is NOT equal to the specified value or not.
isNot
(PredicateV
condition
)
boolean
PredicateV
condition
)Predicate condition |
A value validator. |
boolean |
A result of validation. |
Test whether the current value does NOT fulfill the specified condition or not.
isAbsent
()
boolean
boolean |
A result. |
Check whether the value is absent or not.
isPresent
()
boolean
boolean |
A result. |
Check whether the value is present or not.
isFixed
()
boolean
boolean |
A result. |
Check whether the value is fixed or not.
fix
()
VariableV
V
Variable |
Chainable API. |
Fix this value as immutable.
flip
(Supplier?
R
then
)
VariableR
Supplier?
R
then
)R
R |
|
Supplier then |
An action to perform. |
Variable |
The computed |
Perform the specified action if the value is absent.
flatFlip
(SupplierVariableR
mapper
)
VariableR
SupplierVariableR
mapper
)R
R |
|
Supplier mapper |
The mapping function to apply to a value, if present. |
Variable |
The computed |
If a value is present, returns the result of applying the given Variable
-bearing
mapping function to the value, otherwise returns an empty Variable
.
map
(Function?
V
, ?
R
then
)
VariableR
Function?
V
, ?
R
then
)R
R |
|
Function then |
An action to perform. |
Variable |
The computed |
Perform the specified action if the value is present.
flatMap
(FunctionV
, VariableR
mapper
)
VariableR
FunctionV
, VariableR
mapper
)R
R |
|
Function mapper |
The mapping function to apply to a value, if present. |
Variable |
The computed |
If a value is present, returns the result of applying the given Variable
-bearing
mapping function to the value, otherwise returns an empty Variable
.
next
()
V
V |
The next value. |
Get the value to be set next. The method waits until a new value is set.
observe
()
SignalV
V
Signal |
The |
Observe this Variable
.
observing
()
SignalV
V
Signal |
The |
Observe this Variable
with the current value.
or
(V
other
)
V
V
other
)V other |
A value to be returned if there is no value present, may be null. |
V |
The current value or alternative value. |
Get the current value. If there is no value, returns the specified alternative value.
or
(SupplierV
other
)
V
SupplierV
other
)Supplier other |
A value to be returned if there is no value present, may be null. |
V |
The current value or alternative value. |
Get the current value. If there is no value, returns the specified alternative value.
set
(V
value
)
V
V
value
)V value |
A value to assign. |
V |
A previous value. |
Assign the new value.
set
(SupplierV
value
)
V
SupplierV
value
)Supplier value |
A value generator. |
V |
A previous value. |
Assign the new value.
set
(UnaryOperatorV
value
)
V
UnaryOperatorV
value
)UnaryOperator value |
A value generator. |
V |
A previous value. |
Assign the new value.
to
(ConsumerV
some
)
void
ConsumerV
some
)Consumer some |
A user action. |
Execute the specified action if the value is present.
to
(ConsumerV
some
, Runnable
none
)
void
ConsumerV
some
, Runnable
none
)Consumer some |
A user action. |
Runnable none |
Execute the specified action.
hashCode
()
int
int |
equals
(Object
obj
)
boolean
Object
obj
)Object obj |
|
boolean |
toString
()
String
String |
of
(T
value
)
VariableT
T
value
)T
T |
|
T value |
An actual value, |
Variable |
A created |
Create Variable
with the specified value.
empty
()
VariableT
T
T |
|
Variable |
A new empty |
Create empty Variable
.