public interface NumberExpression
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.
To be able to deal with an unspecified return type, two interfaces
NumberExpression
and its counterpart
NumberBinding
were introduced. That means if the
return type is specified as NumberBinding
, the method will either
return a DoubleBinding
,
FloatBinding
,
LongBinding
or
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 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.
Modifier and Type | Method and Description |
---|---|
NumberBinding |
add(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and another
javafx.beans.value.ObservableNumberValue . |
StringBinding |
asString()
|
StringBinding |
asString(java.util.Locale locale,
java.lang.String format)
|
StringBinding |
asString(java.lang.String format)
|
NumberBinding |
divide(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and another
javafx.beans.value.ObservableNumberValue . |
BooleanBinding |
greaterThan(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than another
javafx.beans.value.ObservableNumberValue . |
BooleanBinding |
greaterThanOrEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to another
javafx.beans.value.ObservableNumberValue . |
BooleanBinding |
isEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this and another javafx.beans.value.ObservableNumberValue are
equal. |
BooleanBinding |
isEqualTo(ObservableNumberValue other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this and another javafx.beans.value.ObservableNumberValue are
equal (with a tolerance). |
BooleanBinding |
isNotEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this and another javafx.beans.value.ObservableNumberValue are
not equal. |
BooleanBinding |
isNotEqualTo(ObservableNumberValue other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this and another javafx.beans.value.ObservableNumberValue are
not equal (with a tolerance). |
BooleanBinding |
lessThan(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than another
javafx.beans.value.ObservableNumberValue . |
BooleanBinding |
lessThanOrEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to another
javafx.beans.value.ObservableNumberValue . |
NumberBinding |
multiply(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and another
javafx.beans.value.ObservableNumberValue . |
NumberBinding |
negate()
Creates a new
NumberBinding that calculates
the negation of NumberExpression . |
NumberBinding |
subtract(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and another
javafx.beans.value.ObservableNumberValue . |
NumberBinding negate()
NumberBinding
that calculates
the negation of NumberExpression
.NumberBinding
NumberBinding add(ObservableNumberValue other)
NumberBinding
that calculates
the sum of this NumberExpression
and another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding subtract(ObservableNumberValue other)
NumberBinding
that calculates
the difference of this NumberExpression
and another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding multiply(ObservableNumberValue other)
NumberBinding
that calculates
the product of this NumberExpression
and another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding divide(ObservableNumberValue other)
NumberBinding
that calculates
the division of this NumberExpression
and another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this and another javafx.beans.value.ObservableNumberValue
are
equal.
When comparing floating-point numbers it is recommended to use the
isEqualTo()
method that
allows a small tolerance.
other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isEqualTo(ObservableNumberValue other, double epsilon)
BooleanBinding
that holds true
if this and another javafx.beans.value.ObservableNumberValue
are
equal (with a tolerance).
Two operands a
and b
are considered equal if
Math.abs(a-b) <= epsilon
.
Allowing a small tolerance is recommended when comparing floating-point numbers because of rounding-errors.
other
- the second ObservableNumberValue
epsilon
- the toleranceBooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isNotEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this and another javafx.beans.value.ObservableNumberValue
are
not equal.
When comparing floating-point numbers it is recommended to use the
isNotEqualTo()
method that allows a small tolerance.
other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isNotEqualTo(ObservableNumberValue other, double epsilon)
BooleanBinding
that holds true
if this and another javafx.beans.value.ObservableNumberValue
are
not equal (with a tolerance).
Two operands a
and b
are considered not equal if
Math.abs(a-b) > epsilon
.
Allowing a small tolerance is recommended when comparing floating-point numbers because of rounding-errors.
other
- the second ObservableNumberValue
epsilon
- the permitted toleranceBooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding greaterThan(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is greater than another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding lessThan(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding greaterThanOrEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding lessThanOrEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to another
javafx.beans.value.ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
java.lang.NullPointerException
- if the other ObservableNumberValue
is null
StringBinding asString()
StringBinding
that holds the value
of the NumberExpression
turned into a String
. If the
value of this NumberExpression
changes, the value of the
StringBinding
will be updated automatically.
The conversion is done without any formatting applied.
StringBinding
StringBinding asString(java.lang.String format)
StringBinding
that holds the value
of the NumberExpression
turned into a String
. If the
value of this NumberExpression
changes, the value of the
StringBinding
will be updated automatically.
The result is formatted according to the formatting String
. See
java.util.Formatter
for formatting rules.
format
- the formatting String
StringBinding
StringBinding asString(java.util.Locale locale, java.lang.String format)
StringBinding
that holds the value
of the NumberExpression
turned into a String
. If the
value of this NumberExpression
changes, the value of the
StringBinding
will be updated automatically.
The result is formatted according to the formatting String
and
the passed in Locale
. See java.util.Formatter
for
formatting rules. See java.util.Locale
for details on
Locale
.
locale
- the Locale to be usedformat
- the formatting String
StringBinding