public abstract interface NumberExpression
  Comment     Returned-by     Constructor-argument     Method-argument     Field-type     Type-bound     Links  

NumberExpression is an javafx.beans.value.ObservableNumberValue plus additional convenience methods to generate bindings in a fluent style.

This API allows to mix types when defining arithmetic operations. The type of the result is defined by the same rules as in the Java Language.

  1. If one of the operands is a double, the result is a double.
  2. If not and one of the operands is a float, the result is a float.
  3. If not and one of the operands is a long, the result is a long.
  4. The result is an integer otherwise.

To be able to deal with an unspecified return type, two interfaces NumberExpression and its counterpart javafx.beans.binding.NumberBinding were introduced. That means if the return type is specified as NumberBinding, the method will either return a javafx.beans.binding.DoubleBinding, javafx.beans.binding.FloatBinding, javafx.beans.binding.LongBinding or javafx.beans.binding.IntegerBinding, depending on the types of the operands.

The API tries to do its best in determining the correct return type, e.g. combining a javafx.beans.value.ObservableNumberValue with a primitive double will always result in a javafx.beans.binding.DoubleBinding. In cases where the return type is not known by the API, it is the responsibility of the developer to call the correct getter (intValue() etc.). If the internal representation does not match the type of the getter, a standard cast is done.

extends ObservableNumberValue

Since:  JavaFX 2.0