112 * Returns a {@code LongExpression} that wraps an
113 * {@link javafx.beans.value.ObservableValue}. If the
114 * {@code ObservableValue} is already a {@code LongExpression}, it
115 * will be returned. Otherwise a new
116 * {@link javafx.beans.binding.LongBinding} is created that is bound to
117 * the {@code ObservableValue}.
118 *
119 * <p>
120 * Note: this method can be used to convert an {@link ObjectExpression} or
121 * {@link javafx.beans.property.ObjectProperty} of specific number type to LongExpression, which
122 * is essentially an {@code ObservableValue<Number>}. See sample below.
123 *
124 * <blockquote><pre>
125 * LongProperty longProperty = new SimpleLongProperty(1L);
126 * ObjectProperty<Long> objectProperty = new SimpleObjectProperty<>(2L);
127 * BooleanBinding binding = longProperty.greaterThan(LongExpression.longExpression(objectProperty));
128 * </pre></blockquote>
129 *
130 * Note: null values will be interpreted as 0L
131 *
132 * @param value
133 * The source {@code ObservableValue}
134 * @return A {@code LongExpression} that wraps the
135 * {@code ObservableValue} if necessary
136 * @throws NullPointerException
137 * if {@code value} is {@code null}
138 * @since JavaFX 8.0
139 */
140 public static <T extends Number> LongExpression longExpression(final ObservableValue<T> value) {
141 if (value == null) {
142 throw new NullPointerException("Value must be specified.");
143 }
144 return (value instanceof LongExpression) ? (LongExpression) value
145 : new LongBinding() {
146 {
147 super.bind(value);
148 }
149
150 @Override
151 public void dispose() {
|
112 * Returns a {@code LongExpression} that wraps an
113 * {@link javafx.beans.value.ObservableValue}. If the
114 * {@code ObservableValue} is already a {@code LongExpression}, it
115 * will be returned. Otherwise a new
116 * {@link javafx.beans.binding.LongBinding} is created that is bound to
117 * the {@code ObservableValue}.
118 *
119 * <p>
120 * Note: this method can be used to convert an {@link ObjectExpression} or
121 * {@link javafx.beans.property.ObjectProperty} of specific number type to LongExpression, which
122 * is essentially an {@code ObservableValue<Number>}. See sample below.
123 *
124 * <blockquote><pre>
125 * LongProperty longProperty = new SimpleLongProperty(1L);
126 * ObjectProperty<Long> objectProperty = new SimpleObjectProperty<>(2L);
127 * BooleanBinding binding = longProperty.greaterThan(LongExpression.longExpression(objectProperty));
128 * </pre></blockquote>
129 *
130 * Note: null values will be interpreted as 0L
131 *
132 * @param <T> The type of Number to be wrapped
133 * @param value
134 * The source {@code ObservableValue}
135 * @return A {@code LongExpression} that wraps the
136 * {@code ObservableValue} if necessary
137 * @throws NullPointerException
138 * if {@code value} is {@code null}
139 * @since JavaFX 8.0
140 */
141 public static <T extends Number> LongExpression longExpression(final ObservableValue<T> value) {
142 if (value == null) {
143 throw new NullPointerException("Value must be specified.");
144 }
145 return (value instanceof LongExpression) ? (LongExpression) value
146 : new LongBinding() {
147 {
148 super.bind(value);
149 }
150
151 @Override
152 public void dispose() {
|