Module javafx.base
Package javafx.beans.binding

# Class When

java.lang.Object
javafx.beans.binding.When

    public class When
    extends Object

Starting point for a binding that calculates a ternary expression.

A ternary expression has the basic form `new When(cond).then(value1).otherwise(value2);`. The expression `cond` needs to be a `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 `ObservableValue`.

Since:
  JavaFX 2.0

- ## Nested Class Summary

  Nested Classes
  Modifier and Type | Class | Description
  --- | --- | ---
  `class` | `When.BooleanConditionBuilder` | An intermediate class needed while assembling the ternary expression.
  `class` | `When.NumberConditionBuilder` | If-then-else expression returning a number.
  `class` | `When.ObjectConditionBuilder<T>` | An intermediate class needed while assembling the ternary expression.
  `class` | `When.StringConditionBuilder` | An intermediate class needed while assembling the ternary expression.

- ## Constructor Summary

  Constructors
  Constructor | Description
  --- | ---
  `When​(ObservableBooleanValue condition)` | The constructor of `When`.

- ## Method Summary

  Modifier and Type | Method | Description
  --- | --- | ---
  `When.BooleanConditionBuilder` | `then​(boolean thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.NumberConditionBuilder` | `then​(double thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.NumberConditionBuilder` | `then​(float thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.NumberConditionBuilder` | `then​(int thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.NumberConditionBuilder` | `then​(long thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.StringConditionBuilder` | `then​(String thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.
  `When.BooleanConditionBuilder` | `then​(ObservableBooleanValue thenValue)` | Defines the `ObservableBooleanValue` which value is returned by the ternary expression if the condition is `true`.
  `When.NumberConditionBuilder` | `then​(ObservableNumberValue thenValue)` | Defines the `ObservableNumberValue` which value is returned by the ternary expression if the condition is `true`.
  `<T> When.ObjectConditionBuilder<T>` | `then​(ObservableObjectValue<T> thenValue)` | Defines the `ObservableObjectValue` which value is returned by the ternary expression if the condition is `true`.
  `When.StringConditionBuilder` | `then​(ObservableStringValue thenValue)` | Defines the `ObservableStringValue` which value is returned by the ternary expression if the condition is `true`.
  `<T> When.ObjectConditionBuilder<T>` | `then​(T thenValue)` | Defines a constant value of the ternary expression, that is returned if the condition is `true`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### When

    public When​(ObservableBooleanValue condition)
    The constructor of `When`.
    Parameters:
      `condition` - the condition of the ternary expression

- ## Method Details

  - ### then

    public When.NumberConditionBuilder then​(ObservableNumberValue thenValue)
    Defines the `ObservableNumberValue` which value is returned by the ternary expression if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.NumberConditionBuilder then​(double thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.NumberConditionBuilder then​(float thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.NumberConditionBuilder then​(long thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.NumberConditionBuilder then​(int thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.BooleanConditionBuilder then​(ObservableBooleanValue thenValue)
    Defines the `ObservableBooleanValue` which value is returned by the ternary expression if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.BooleanConditionBuilder then​(boolean thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.StringConditionBuilder then​(ObservableStringValue thenValue)
    Defines the `ObservableStringValue` which value is returned by the ternary expression if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public When.StringConditionBuilder then​(String thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public <T> When.ObjectConditionBuilder<T> then​(ObservableObjectValue<T> thenValue)
    Defines the `ObservableObjectValue` which value is returned by the ternary expression if the condition is `true`.
    Type Parameters:
      `T` - the type of the intermediate result
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch

  - ### then

    public <T> When.ObjectConditionBuilder<T> then​(T thenValue)
    Defines a constant value of the ternary expression, that is returned if the condition is `true`.
    Type Parameters:
      `T` - the type of the intermediate result
    Parameters:
      `thenValue` - the value
    Returns:
      the intermediate result which still requires the otherwise-branch