public class NumberBindings extends Object
| Constructor and Description |
|---|
NumberBindings() |
| Modifier and Type | Method and Description |
|---|---|
static DoubleBinding |
asDouble(ObservableValue<Number> source)
|
static FloatBinding |
asFloat(ObservableValue<Number> source)
|
static IntegerBinding |
asInteger(ObservableValue<Number> source)
|
static LongBinding |
asLong(ObservableValue<Number> source)
|
static NumberBinding |
divideSafe(double dividend,
ObservableNumberValue divisor)
An number binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static IntegerBinding |
divideSafe(int dividend,
ObservableIntegerValue divisor)
An integer binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static IntegerBinding |
divideSafe(ObservableIntegerValue dividend,
int divisor)
An integer binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static IntegerBinding |
divideSafe(ObservableIntegerValue dividend,
ObservableIntegerValue divisor)
A number binding with the division of the two observable number values.
|
static IntegerBinding |
divideSafe(ObservableIntegerValue dividend,
ObservableIntegerValue divisor,
int defaultValue)
An integer binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static IntegerBinding |
divideSafe(ObservableIntegerValue dividend,
ObservableIntegerValue divisor,
ObservableIntegerValue defaultValue)
An integer binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static NumberBinding |
divideSafe(ObservableNumberValue dividend,
double divisor)
An number binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static NumberBinding |
divideSafe(ObservableNumberValue dividend,
ObservableNumberValue divisor)
An number binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static NumberBinding |
divideSafe(ObservableNumberValue dividend,
ObservableNumberValue divisor,
double defaultValue)
An number binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static NumberBinding |
divideSafe(ObservableNumberValue dividend,
ObservableNumberValue divisor,
ObservableNumberValue defaultValue)
An number binding of a division that won’t throw an
ArithmeticException when a division by zero happens. |
static BooleanBinding |
isInfinite(ObservableDoubleValue observableValue)
A boolean binding that is
true if the given observable double is Infinite. |
static BooleanBinding |
isNaN(ObservableDoubleValue observableValue)
A boolean binding that is
true if the given observable double is Not a Number. |
public static BooleanBinding isNaN(ObservableDoubleValue observableValue)
A boolean binding that is true if the given observable double is Not a Number. See Double.isNaN(double).
observableValue - the observable double value to use for the binding.public static BooleanBinding isInfinite(ObservableDoubleValue observableValue)
A boolean binding that is true if the given observable double is Infinite. See Double.isInfinite(double).
observableValue - the observable double value to use for the binding.public static NumberBinding divideSafe(ObservableNumberValue dividend, ObservableNumberValue divisor)
An number binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more informations.
dividend - the observable value used as dividenddivisor - the observable value used as divisorpublic static NumberBinding divideSafe(double dividend, ObservableNumberValue divisor)
An number binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more informations.
dividend - the value used as dividenddivisor - the observable value used as divisorpublic static NumberBinding divideSafe(ObservableNumberValue dividend, double divisor)
An number binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more informations.
dividend - the observable value used as dividenddivisor - the value used as divisorpublic static NumberBinding divideSafe(ObservableNumberValue dividend, ObservableNumberValue divisor, ObservableNumberValue defaultValue)
An number binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more informations.
dividend - the observable value used as dividenddivisor - the observable value used as divisordefaultValue - the observable value that is used as default value. The binding will have this value when a division by zero happens.public static NumberBinding divideSafe(ObservableNumberValue dividend, ObservableNumberValue divisor, double defaultValue)
An number binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more information.
dividend - the observable value used as dividenddivisor - the observable value used as divisordefaultValue - the default value. The binding will have this value when a division by zero happens.public static IntegerBinding divideSafe(ObservableIntegerValue dividend, ObservableIntegerValue divisor)
A number binding with the division of the two observable number values. The difference to the existing bindings ( Bindings.divide(javafx.beans.value.ObservableNumberValue, javafx.beans.value.ObservableNumberValue)) is that this binding will not throw an ArithmeticException when the second param (the divisor) is zero. Instead an default value of 0 is returned.
This can be useful because bindings like this aren’t working as expected:
IntegerProperty a = ...;
IntegerProperty b = ...;
NumberBinding result = Bindings
.when(b.isEqualTo(0))
.then(0)
.otherwise(a.divide(b));
At first one would expect that this binding will have a value 0 when b is 0. Instead the binding in the example will throw an ArithmeticException when b has an (initial) value of 0. The when-otherwise construct doesn’t help in this case because the divide binding will still be evaluated.
In such cases you can use the binding created by this method which makes this distinction internally and won’t throw an exception.
If you 0 isn’t suitable as a default value for your use case you can use the overloaded method divideSafe(javafx.beans.value.ObservableIntegerValue, javafx.beans.value.ObservableIntegerValue,
int).
dividend - the observable value used as dividenddivisor - the observable value used as divisorpublic static IntegerBinding divideSafe(int dividend, ObservableIntegerValue divisor)
An integer binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more information.
dividend - the value used as dividenddivisor - the observable value used as divisorpublic static IntegerBinding divideSafe(ObservableIntegerValue dividend, int divisor)
An integer binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more information.
dividend - the observable value used as dividenddivisor - the value used as divisorpublic static IntegerBinding divideSafe(ObservableIntegerValue dividend, ObservableIntegerValue divisor, ObservableIntegerValue defaultValue)
An integer binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more information.
dividend - the observable value used as dividenddivisor - the observable value used as divisordefaultValue - the observable value that is used as default value. The binding will have this value when a division by zero happens.public static IntegerBinding divideSafe(ObservableIntegerValue dividend, ObservableIntegerValue divisor, int defaultValue)
An integer binding of a division that won’t throw an ArithmeticException when a division by zero happens. See divideSafe(javafx.beans.value.ObservableIntegerValue,
javafx.beans.value.ObservableIntegerValue) for more information.
dividend - the observable value used as dividenddivisor - the observable value used as divisordefaultValue - the default value. The binding will have this value when a division by zero happens.public static IntegerBinding asInteger(ObservableValue<Number> source)
Converts the given ObservableValue of type Number into an IntegerBinding.
This is done by the Number.intValue() method.
This method can be useful in situations where an operation or component only provides an observable value of type number that you like to use to create calculation bindings.
It’s the like a reverse-method of IntegerExpression.asObject().
source - the observable value that will be converted.public static DoubleBinding asDouble(ObservableValue<Number> source)
Converts the given ObservableValue of type Number into an DoubleBinding.
This is done by the Number.doubleValue() method.
This method can be useful in situations where an operation or component only provides an observable value of type number that you like to use to create calculation bindings.
It’s the like a reverse-method of DoubleExpression.asObject().
source - the observable value that will be converted.public static FloatBinding asFloat(ObservableValue<Number> source)
Converts the given ObservableValue of type Number into an FloatBinding.
This is done by the Number.floatValue() method.
This method can be useful in situations where an operation or component only provides an observable value of type number that you like to use to create calculation bindings.
It’s the like a reverse-method of FloatExpression.asObject().
source - the observable value that will be converted.public static LongBinding asLong(ObservableValue<Number> source)
Converts the given ObservableValue of type Number into an LongBinding.
This is done by the Number.longValue() method.
This method can be useful in situations where an operation or component only provides an observable value of type number that you like to use to create calculation bindings.
It’s the like a reverse-method of LongExpression.asObject().
source - the observable value that will be converted.