public interface NumberExpression extends ObservableNumberValue
NumberExpression
is a
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 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 (ObservableNumberValue.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(double other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and a constant value. |
NumberBinding |
add(float other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and a constant value. |
NumberBinding |
add(int other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and a constant value. |
NumberBinding |
add(long other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and a constant value. |
NumberBinding |
add(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the sum of this NumberExpression and another
ObservableNumberValue . |
StringBinding |
asString()
|
StringBinding |
asString(Locale locale,
String format)
|
StringBinding |
asString(String format)
|
NumberBinding |
divide(double other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and a constant value. |
NumberBinding |
divide(float other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and a constant value. |
NumberBinding |
divide(int other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and a constant value. |
NumberBinding |
divide(long other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and a constant value. |
NumberBinding |
divide(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the division of this NumberExpression and another
ObservableNumberValue . |
BooleanBinding |
greaterThan(double other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than a constant value. |
BooleanBinding |
greaterThan(float other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than a constant value. |
BooleanBinding |
greaterThan(int other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than a constant value. |
BooleanBinding |
greaterThan(long other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than a constant value. |
BooleanBinding |
greaterThan(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than another
ObservableNumberValue . |
BooleanBinding |
greaterThanOrEqualTo(double other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to a constant
value. |
BooleanBinding |
greaterThanOrEqualTo(float other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to a constant
value. |
BooleanBinding |
greaterThanOrEqualTo(int other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to a constant
value. |
BooleanBinding |
greaterThanOrEqualTo(long other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to a constant
value. |
BooleanBinding |
greaterThanOrEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is greater than or equal to another
ObservableNumberValue . |
BooleanBinding |
isEqualTo(double other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is equal to a constant value (with a
tolerance). |
BooleanBinding |
isEqualTo(float other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is equal to a constant value (with a
tolerance). |
BooleanBinding |
isEqualTo(int other)
|
BooleanBinding |
isEqualTo(int other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is equal to a constant value (with a
tolerance). |
BooleanBinding |
isEqualTo(long other)
|
BooleanBinding |
isEqualTo(long other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is equal to a constant value (with a
tolerance). |
BooleanBinding |
isEqualTo(ObservableNumberValue other)
|
BooleanBinding |
isEqualTo(ObservableNumberValue other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this and another ObservableNumberValue are
equal (with a tolerance). |
BooleanBinding |
isNotEqualTo(double other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value (with a
tolerance). |
BooleanBinding |
isNotEqualTo(float other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value (with a
tolerance). |
BooleanBinding |
isNotEqualTo(int other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value. |
BooleanBinding |
isNotEqualTo(int other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value (with a
tolerance). |
BooleanBinding |
isNotEqualTo(long other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value. |
BooleanBinding |
isNotEqualTo(long other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this NumberExpression is not equal to a constant value (with a
tolerance). |
BooleanBinding |
isNotEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this and another ObservableNumberValue are
not equal. |
BooleanBinding |
isNotEqualTo(ObservableNumberValue other,
double epsilon)
Creates a new
BooleanBinding that holds true
if this and another ObservableNumberValue are
not equal (with a tolerance). |
BooleanBinding |
lessThan(double other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than a constant value. |
BooleanBinding |
lessThan(float other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than a constant value. |
BooleanBinding |
lessThan(int other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than a constant value. |
BooleanBinding |
lessThan(long other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than a constant value. |
BooleanBinding |
lessThan(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is lesser than another
ObservableNumberValue . |
BooleanBinding |
lessThanOrEqualTo(double other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to a constant
value. |
BooleanBinding |
lessThanOrEqualTo(float other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to a constant
value. |
BooleanBinding |
lessThanOrEqualTo(int other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to a constant
value. |
BooleanBinding |
lessThanOrEqualTo(long other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to a constant
value. |
BooleanBinding |
lessThanOrEqualTo(ObservableNumberValue other)
Creates a new
BooleanBinding that holds true
if this NumberExpression is less than or equal to another
ObservableNumberValue . |
NumberBinding |
multiply(double other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and a constant value. |
NumberBinding |
multiply(float other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and a constant value. |
NumberBinding |
multiply(int other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and a constant value. |
NumberBinding |
multiply(long other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and a constant value. |
NumberBinding |
multiply(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the product of this NumberExpression and another
ObservableNumberValue . |
NumberBinding |
negate()
Creates a new
NumberBinding that calculates
the negation of NumberExpression . |
NumberBinding |
subtract(double other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and a constant value. |
NumberBinding |
subtract(float other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and a constant value. |
NumberBinding |
subtract(int other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and a constant value. |
NumberBinding |
subtract(long other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and a constant value. |
NumberBinding |
subtract(ObservableNumberValue other)
Creates a new
NumberBinding that calculates
the difference of this NumberExpression and another
ObservableNumberValue . |
doubleValue, floatValue, intValue, longValue
addListener, getValue, removeListener
addListener, removeListener
NumberBinding negate()
NumberBinding
that calculates
the negation of NumberExpression
.NumberBinding
NumberBinding add(ObservableNumberValue other)
NumberBinding
that calculates
the sum of this NumberExpression
and another
ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding add(double other)
NumberBinding
that calculates
the sum of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding add(float other)
NumberBinding
that calculates
the sum of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding add(long other)
NumberBinding
that calculates
the sum of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding add(int other)
NumberBinding
that calculates
the sum of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding subtract(ObservableNumberValue other)
NumberBinding
that calculates
the difference of this NumberExpression
and another
ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding subtract(double other)
NumberBinding
that calculates
the difference of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding subtract(float other)
NumberBinding
that calculates
the difference of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding subtract(long other)
NumberBinding
that calculates
the difference of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding subtract(int other)
NumberBinding
that calculates
the difference of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding multiply(ObservableNumberValue other)
NumberBinding
that calculates
the product of this NumberExpression
and another
ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding multiply(double other)
NumberBinding
that calculates
the product of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding multiply(float other)
NumberBinding
that calculates
the product of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding multiply(long other)
NumberBinding
that calculates
the product of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding multiply(int other)
NumberBinding
that calculates
the product of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding divide(ObservableNumberValue other)
NumberBinding
that calculates
the division of this NumberExpression
and another
ObservableNumberValue
.other
- the second ObservableNumberValue
NumberBinding
NullPointerException
- if the other ObservableNumberValue
is null
NumberBinding divide(double other)
NumberBinding
that calculates
the division of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding divide(float other)
NumberBinding
that calculates
the division of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding divide(long other)
NumberBinding
that calculates
the division of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
NumberBinding divide(int other)
NumberBinding
that calculates
the division of this NumberExpression
and a constant value.other
- the constant valueNumberBinding
BooleanBinding isEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this and another 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
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isEqualTo(ObservableNumberValue other, double epsilon)
BooleanBinding
that holds true
if this and another 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
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isEqualTo(double other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value (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 constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isEqualTo(float other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value (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 constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isEqualTo(long other)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value.
When comparing floating-point numbers it is recommended to use the
isEqualTo()
method that allows a small
tolerance.
other
- the constant valueBooleanBinding
BooleanBinding isEqualTo(long other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value (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 constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isEqualTo(int other)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value.
When comparing floating-point numbers it is recommended to use the
isEqualTo()
method that allows a small
tolerance.
other
- the constant valueBooleanBinding
BooleanBinding isEqualTo(int other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is equal to a constant value (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.
other
- the constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isNotEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this and another 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
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isNotEqualTo(ObservableNumberValue other, double epsilon)
BooleanBinding
that holds true
if this and another 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
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding isNotEqualTo(double other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value (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.
other
- the constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isNotEqualTo(float other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value (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.
other
- the constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isNotEqualTo(long other)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value.
When comparing floating-point numbers it is recommended to use the
isNotEqualTo()
method that allows a
small tolerance.
other
- the constant valueBooleanBinding
BooleanBinding isNotEqualTo(long other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value (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.
other
- the constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding isNotEqualTo(int other)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value.
When comparing floating-point numbers it is recommended to use the
isNotEqualTo()
method that allows a
small tolerance.
other
- the constant valueBooleanBinding
BooleanBinding isNotEqualTo(int other, double epsilon)
BooleanBinding
that holds true
if this NumberExpression
is not equal to a constant value (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.
other
- the constant valueepsilon
- the permitted toleranceBooleanBinding
BooleanBinding greaterThan(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is greater than another
ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding greaterThan(double other)
BooleanBinding
that holds true
if this NumberExpression
is greater than a constant value.other
- the constant valueBooleanBinding
BooleanBinding greaterThan(float other)
BooleanBinding
that holds true
if this NumberExpression
is greater than a constant value.other
- the constant valueBooleanBinding
BooleanBinding greaterThan(long other)
BooleanBinding
that holds true
if this NumberExpression
is greater than a constant value.other
- the constant valueBooleanBinding
BooleanBinding greaterThan(int other)
BooleanBinding
that holds true
if this NumberExpression
is greater than a constant value.other
- the constant valueBooleanBinding
BooleanBinding lessThan(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than another
ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding lessThan(double other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than a constant value.other
- the constant valueBooleanBinding
BooleanBinding lessThan(float other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than a constant value.other
- the constant valueBooleanBinding
BooleanBinding lessThan(long other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than a constant value.other
- the constant valueBooleanBinding
BooleanBinding lessThan(int other)
BooleanBinding
that holds true
if this NumberExpression
is lesser than a constant value.other
- the constant valueBooleanBinding
BooleanBinding greaterThanOrEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to another
ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding greaterThanOrEqualTo(double other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding greaterThanOrEqualTo(float other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding greaterThanOrEqualTo(long other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding greaterThanOrEqualTo(int other)
BooleanBinding
that holds true
if this NumberExpression
is greater than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding lessThanOrEqualTo(ObservableNumberValue other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to another
ObservableNumberValue
.other
- the second ObservableNumberValue
BooleanBinding
NullPointerException
- if the other ObservableNumberValue
is null
BooleanBinding lessThanOrEqualTo(double other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding lessThanOrEqualTo(float other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding lessThanOrEqualTo(long other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to a constant
value.other
- the constant valueBooleanBinding
BooleanBinding lessThanOrEqualTo(int other)
BooleanBinding
that holds true
if this NumberExpression
is less than or equal to a constant
value.other
- the constant valueBooleanBinding
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(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(Locale locale, 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
.
format
- the formatting String
StringBinding
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 2008, 2017, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.