public class When
extends java.lang.Object
A ternary expression has the basic form
new When(cond).then(value1).otherwise(value2);
. The expression
cond
needs to be a javafx.beans.value.ObservableBooleanValue
.
Based on the value of cond
, the binding contains the value of
value1
(if cond.getValue() == true
) or value2
(if
cond.getValue() == false
). The values value1
and
value2
have to be of the same type. They can be constant values or
implementations of javafx.beans.value.ObservableValue
.
Modifier and Type | Class and Description |
---|---|
private class |
When.BooleanCondition
If-then-else expression returning Boolean.
|
class |
When.BooleanConditionBuilder
An intermediate class needed while assembling the ternary expression.
|
class |
When.NumberConditionBuilder
If-then-else expression returning a number.
|
private class |
When.ObjectCondition<T>
If-then-else expression returning general objects.
|
class |
When.ObjectConditionBuilder<T>
An intermediate class needed while assembling the ternary expression.
|
private class |
When.StringCondition
If-then-else expression returning String.
|
class |
When.StringConditionBuilder
An intermediate class needed while assembling the ternary expression.
|
private static class |
When.WhenListener |
Modifier and Type | Field and Description |
---|---|
private ObservableBooleanValue |
condition |
Constructor and Description |
---|
When(ObservableBooleanValue condition)
The constructor of
When . |
Modifier and Type | Method and Description |
---|---|
private static NumberBinding |
createNumberCondition(ObservableBooleanValue condition,
ObservableNumberValue thenValue,
ObservableNumberValue otherwiseValue) |
<T> When.ObjectConditionBuilder<T> |
then(<any> thenValue)
Defines the
javafx.beans.value.ObservableObjectValue which value
is returned by the ternary expression if the condition is true . |
When.BooleanConditionBuilder |
then(ObservableBooleanValue thenValue)
Defines the
javafx.beans.value.ObservableBooleanValue which value
is returned by the ternary expression if the condition is true . |
When.NumberConditionBuilder |
then(ObservableNumberValue thenValue)
Defines the
javafx.beans.value.ObservableNumberValue which value
is returned by the ternary expression if the condition is true . |
When.StringConditionBuilder |
then(ObservableStringValue thenValue)
Defines the
javafx.beans.value.ObservableStringValue which value
is returned by the ternary expression if the condition is true . |
public When(ObservableBooleanValue condition)
When
.condition
- the condition of the ternary expressionprivate static NumberBinding createNumberCondition(ObservableBooleanValue condition, ObservableNumberValue thenValue, ObservableNumberValue otherwiseValue)
public When.NumberConditionBuilder then(ObservableNumberValue thenValue)
javafx.beans.value.ObservableNumberValue
which value
is returned by the ternary expression if the condition is true
.thenValue
- the valuepublic When.BooleanConditionBuilder then(ObservableBooleanValue thenValue)
javafx.beans.value.ObservableBooleanValue
which value
is returned by the ternary expression if the condition is true
.thenValue
- the valuepublic When.StringConditionBuilder then(ObservableStringValue thenValue)
javafx.beans.value.ObservableStringValue
which value
is returned by the ternary expression if the condition is true
.thenValue
- the valuepublic <T> When.ObjectConditionBuilder<T> then(<any> thenValue)
javafx.beans.value.ObservableObjectValue
which value
is returned by the ternary expression if the condition is true
.T
- the type of the intermediate resultthenValue
- the value