private NumberBinding getDouble(AnimatableField field, NodeModel node, KeyValueModel keyValue, KeyFrameModel keyFrame) { DoubleBinding currentValue = ModelFunctions.toDoubleBinding(keyValue.valueProperty()); KeyFrameModel earlier = getEarlierKeyFrameWithNonNullValue(field, node, keyFrame); KeyFrameModel later = getLaterKeyFrameWithNonNullValue(field, node, keyFrame); if (earlier != null) { DoubleProperty earlierTime = earlier.absoluteTimeProperty(); double earlierValue = (Double) earlier.getKeyValues().get(node).get(field).getValue(); if (later != null) { DoubleProperty laterTime = later.absoluteTimeProperty(); double laterValue = (Double) later.getKeyValues().get(node).get(field).getValue(); DoubleBinding interpolated = Bindings.createDoubleBinding(() -> { double timeFraction = (keyFrame.getAbsoluteTime() - earlierTime.get()) / (laterTime.get() - earlierTime.get()); double interpolatorFactor = later.getKeyValues().get(node).get(field).getInterpolator().curve(timeFraction); return (double) Math.round(earlierValue + (laterValue - earlierValue) * interpolatorFactor); }, earlierTime, laterTime, keyFrame.absoluteTimeProperty()); return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(interpolated); } else { return Bindings.when(keyValue.valueProperty().isNotNull()).then(currentValue).otherwise(earlierValue); } } else { return currentValue; } }
public RfxAppTitleBar(UserInterfaceContainer userInterfaceContainer) { RfxWindow rfxWindow=userInterfaceContainer.get(RfxWindow.class); BooleanBinding windowExtraHighBinding = rfxWindow.getExtraHighBinding(); setMinHeight(BAR_HEIGHT); visibleProperty().bind(windowExtraHighBinding); NumberBinding heightBinding = Bindings.when(windowExtraHighBinding).then(BAR_HEIGHT) .otherwise(0); minHeightProperty().bind(heightBinding); maxHeightProperty().bind(heightBinding); String title = getTitle(userInterfaceContainer); Label titleLabel = new Label(title); String style = new RfxStyleProperties() .setTextFill(MaterialColorSetCssName.PRIMARY.FOREGROUND1()) .setAlignment(Pos.CENTER_LEFT).setFont(MaterialFont.getTitle()) .setPadding(0, 0, 0, 16).toString(); titleLabel.setStyle(style); getChildren().add(titleLabel); }
/** * @param args */ public static void main(String[] args) { Bill bill = new Bill(); bill.amountDueProperty().addListener( new ChangeListener<Object>() { @Override public void changed(ObservableValue var, Object oldValue, Object newValue) { System.out.println("Bill is changed arg0 : "+var); System.out.println("Bill is changed arg1 : "+oldValue); System.out.println("Bill is changed arg2 : "+newValue); } }); bill.setAmountDue(56); bill.setAmountDue(66); IntegerProperty num1 = new SimpleIntegerProperty(23); IntegerProperty num2 = new SimpleIntegerProperty(26); NumberBinding sum = num1.add(num2); System.out.println("Sum : "+sum.getValue()); num2.set(56); System.out.println("Sum : "+sum.getValue()); }
@Test public void testDivideSafeDouble(){ DoubleProperty a = new SimpleDoubleProperty(); DoubleProperty b = new SimpleDoubleProperty(); final NumberBinding quotient = NumberBindings.divideSafe(a, b); assertThat(quotient).hasValue(0.0); a.set(10); assertThat(quotient).hasValue(0.0); b.set(5); assertThat(quotient).hasValue(2.0); a.set(12); assertThat(quotient).hasValue(2.4); b.set(0); assertThat(quotient).hasValue(0.0); }
@Test public void testDivideSafeDoubleWithDefaultValue(){ DoubleProperty a = new SimpleDoubleProperty(); DoubleProperty b = new SimpleDoubleProperty(); DoubleProperty defaultValue = new SimpleDoubleProperty(3.2); final NumberBinding quotient = NumberBindings.divideSafe(a, b, defaultValue); assertThat(quotient).hasSameValue(defaultValue); assertThat(quotient).hasSameValue(defaultValue); a.set(10); assertThat(quotient).hasSameValue(defaultValue); b.set(5); assertThat(quotient).hasValue(2.0); a.set(12); assertThat(quotient).hasValue(2.4); b.set(0); assertThat(quotient).hasSameValue(defaultValue); }
/** * {@inheritDoc} */ @Override protected void bind() { final Game g = object(); view().getTimeLabel().textProperty().bind(g.timeEllapsedProperty()); // Bind number of success and failure to UI objects view().getSuccessLabel().textProperty().bind(g.successCountProperty().asString()); view().getFailureLabel().textProperty().bind(g.failureCountProperty().asString()); if (g.getSuccessCount() > 0) { // Compute Hit ratio final NumberBinding totalattempt = g.successCountProperty().add(g.failureCountProperty()); final NumberBinding ratio = Bindings.when(totalattempt.greaterThan(0)) .then(Bindings.divide(g.successCountProperty().multiply(100), totalattempt)) .otherwise(0); view().getRatioLabel().textProperty().bind(ratio.asString().concat("%")); } }
public NumberBinding failureFractionProperty() { /* * Note: a bug in JavaFX causes the division to be evaluated when * constructing the when binding, throwing an ArithmeticException. * * As a workaround, we implement the conditional division ourselves. */ // Bindings.when(runsCountProperty().isEqualTo(0)).then(0) // .otherwise(failedRunsCountProperty().divide(runsCountProperty())); return Bindings.createFloatBinding(new Callable<Float>() { @Override public Float call() throws Exception { int failedRuns = failedRunsCountProperty().get(); int totalRuns = runsCountProperty().get(); return (totalRuns == 0) ? 0f : ((float) failedRuns) / ((float) totalRuns); } }, failedRunsCountProperty(), testRunsProperty()); }
private void bindHeight() { if (this.groups.size() == 0) { this.internalHeightProperty.set(-1 * Y_SPACER); return; } NumberBinding lastHeight = null; for (GroupInterface aGroup : this.groups) { lastHeight = (null == lastHeight) ? Bindings.add(0, aGroup.heightProperty()) : Bindings.max(lastHeight, aGroup.heightProperty()); } if (null != this.node && this.node.isShared()) lastHeight = lastHeight.add(20); this.internalHeightProperty.bind(lastHeight); }
private void bindWidth() { if (this.groups.size() == 0) { this.widthProperty.set(NODE_WIDTH); return; } NumberBinding lastWidth = null; for (GroupInterface aGroup : this.groups) { lastWidth = (null == lastWidth) ? Bindings.add(0, aGroup.widthProperty()) : Bindings.add(lastWidth, aGroup.widthProperty()).add(X_SPACER); } if (null != this.node && this.node.isShared()) lastWidth = lastWidth.add(20); this.widthProperty.bind(lastWidth); }
private QuadCurve drawCurve(double startAngle, double endAngle){ // mmm there is something that escapes to me about getting radius back... DoubleProperty radius = new SimpleDoubleProperty(plotRadiusBinding.doubleValue()); radius.bind(plotRadiusBinding); DoubleProperty center = new SimpleDoubleProperty(plotCenterBinding.doubleValue()); center.bind(plotCenterBinding); NumberBinding xSourceBinding = new CartesianXBinding(radius, center, startAngle, circleThickness, sourceGapFromArc); NumberBinding ySourceBinding = new CartesianYBinding(radius, center, startAngle, circleThickness, sourceGapFromArc); NumberBinding xSinkBinding = new CartesianXBinding(radius, center, endAngle, circleThickness, sinkGapFromArc); NumberBinding ySinkBinding = new CartesianYBinding(radius, center, endAngle, circleThickness, sinkGapFromArc); QuadCurve quad = new QuadCurve(); quad.setStroke(Color.GREY); // it could be managed also by a binder quad.setStrokeWidth(strokeWidth); quad.setFill(null); quad.startXProperty().bind(xSourceBinding); quad.startYProperty().bind(ySourceBinding); quad.endXProperty().bind(xSinkBinding); quad.endYProperty().bind(ySinkBinding); quad.controlXProperty().bind(plotCenterBinding); quad.controlYProperty().bind(plotCenterBinding.add(linkTension)); // Visualize arc only if it links two points that are distant enough. Check that: //min(distance, 2*PI-distance) * plotRadius > threshold; double distance = abs(endAngle - startAngle); double l = min(distance, 2*PI-distance); BooleanBinding visibleBinding = Bindings.greaterThan(plotRadiusBinding.multiply(l), linkWidthThreshold); quad.visibleProperty().bind(visibleBinding); return quad; }
public NumberBinding getDuration() { return Bindings.createLongBinding(() -> { if (startTime.get() == -1) { return 0L; } else if (endTime.get() == -1) { return System.currentTimeMillis() - startTime.get(); } else { return endTime.get() - startTime.get(); } }, startTime, endTime); }
LogLine( BindableValue<Font> fontValue, NumberBinding widthProperty, Paint bkgColor, Paint fillColor ) { setBackground( FxUtils.simpleBackground( bkgColor ) ); setTextFill( fillColor ); fontProperty().bind( fontValue ); minWidthProperty().bind( widthProperty ); getStyleClass().add( "log-line" ); }
@MustCallOnJavaFXThread public LogView( BindableValue<Font> fontValue, ReadOnlyDoubleProperty widthProperty, HighlightOptions highlightOptions, FileContentReader fileContentReader, TaskRunner taskRunner ) { this.highlightOptions = highlightOptions; this.fileContentReader = fileContentReader; this.taskRunner = taskRunner; this.selectionHandler = new SelectionHandler( this ); this.file = fileContentReader.getFile(); final LogLineColors logLineColors = highlightOptions.logLineColorsFor( "" ); final NumberBinding width = Bindings.max( widthProperty(), widthProperty ); logLineFactory = () -> new LogLine( fontValue, width, logLineColors.getBackground(), logLineColors.getFill() ); for ( int i = 0; i < MAX_LINES; i++ ) { getChildren().add( logLineFactory.get() ); } this.colorChangeListener = ( Observable observable ) -> { for ( int i = 0; i < MAX_LINES; i++ ) { updateLine( i ); } }; highlightOptions.getObservableExpressions().addListener( colorChangeListener ); highlightOptions.getStandardLogColors().addListener( colorChangeListener ); tailingFile.addListener( event -> { if ( tailingFile.get() ) { onFileChange(); } } ); this.fileChangeWatcher = new FileChangeWatcher( file, taskRunner, this::onFileChange ); }
@SuppressWarnings("rawtypes") public CustomTableView(){ this.table = new TableView<S>(); final GridPane grid = new GridPane(); this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){ @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) { grid.getColumnConstraints().clear(); ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()]; StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()]; int i=0; for(TableColumn column : CustomTableView.this.table.getColumns()){ CustomTableColumn col = (CustomTableColumn)column; ColumnConstraints consta = new ColumnConstraints(); consta.setPercentWidth(col.getPercentWidth()); StackPane sp = new StackPane(); if(i==0){ NumberBinding diff = sp.widthProperty().subtract(3.75); // Quick fix for not showing the horizantal scroll bar. column.prefWidthProperty().bind(diff); }else{ column.prefWidthProperty().bind(sp.widthProperty()); } arr1[i] = consta; arr2[i] = sp; i++; } grid.getColumnConstraints().addAll(arr1); grid.addRow(0, arr2); } }); getChildren().addAll(grid,table); }
@SuppressWarnings("rawtypes") public CustomTableView(){ this.table = new TableView<S>(); //this.table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); this.table.setColumnResizePolicy(TableView.UNCONSTRAINED_RESIZE_POLICY); final GridPane grid = new GridPane(); this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){ @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) { grid.getColumnConstraints().clear(); ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()]; StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()]; int i=0; for(TableColumn column : CustomTableView.this.table.getColumns()){ CustomTableColumn col = (CustomTableColumn)column; ColumnConstraints consta = new ColumnConstraints(); consta.setPercentWidth(col.getPercentWidth()); StackPane sp = new StackPane(); if(i==0){ // Quick fix for not showing the horizantal scroll bar. NumberBinding diff = sp.widthProperty().subtract(3.75); column.prefWidthProperty().bind(diff); }else{ column.prefWidthProperty().bind(sp.widthProperty()); } arr1[i] = consta; arr2[i] = sp; i++; } grid.getColumnConstraints().addAll(arr1); grid.addRow(0, arr2); } }); getChildren().addAll(grid,table); }
@SuppressWarnings("rawtypes") public CustomTableView(){ this.table = new TableView<s>(); final GridPane grid = new GridPane(); this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){ public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) { grid.getColumnConstraints().clear(); ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()]; StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()]; int i=0; for(TableColumn column : CustomTableView.this.table.getColumns()){ CustomTableColumn col = (CustomTableColumn)column; ColumnConstraints consta = new ColumnConstraints(); consta.setPercentWidth(col.getPercentWidth()); StackPane sp = new StackPane(); if(i==0){ // Quick fix for not showing the horizantal scroll bar. NumberBinding diff = sp.widthProperty().subtract(3.75); column.prefWidthProperty().bind(diff); }else{ column.prefWidthProperty().bind(sp.widthProperty()); } arr1[i] = consta; arr2[i] = sp; i++; } grid.getColumnConstraints().addAll(arr1); grid.addRow(0, arr2); } }); getChildren().addAll(grid,table); }
@SuppressWarnings("rawtypes") public CustomTableView(){ this.table = new TableView<S>(); this.grid = new GridPane(); this.table.getColumns().addListener(new ListChangeListener<TableColumn>(){ @Override public void onChanged(javafx.collections.ListChangeListener.Change<? extends TableColumn> arg0) { grid.getColumnConstraints().clear(); ColumnConstraints[] arr1 = new ColumnConstraints[CustomTableView.this.table.getColumns().size()]; StackPane[] arr2 = new StackPane[CustomTableView.this.table.getColumns().size()]; int i=0; for(TableColumn column : CustomTableView.this.table.getColumns()){ CustomTableColumn col = (CustomTableColumn)column; ColumnConstraints consta = new ColumnConstraints(); consta.setPercentWidth(col.getPercentWidth()); StackPane sp = new StackPane(); if(i==0){ NumberBinding diff = sp.widthProperty().subtract(3); // Quick fix for not showing the horizantal scroll bar. column.prefWidthProperty().bind(diff); }else{ column.prefWidthProperty().bind(sp.widthProperty()); } arr1[i] = consta; arr2[i] = sp; i++; } grid.getColumnConstraints().addAll(arr1); grid.addRow(0, arr2); } }); getChildren().addAll(grid,table); }
@Test public void testSumOfFloatCollection() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding sum = CollectionBindings.sum(numbers); assertThat(sum).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f); assertThat(sum).hasValue(53.0); numbers.add(34f); assertThat(sum).hasValue(87.0); }
@Test public void testMinOfIntegerCollection() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, 0); assertThat(min).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 8, 13, 21); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfLongCollection() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, 0); assertThat(min).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfFloatCollection() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, 0); assertThat(min).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfDoubleCollection() { ObservableList<Double> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, 0); assertThat(min).hasValue(0.0); numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMaxOfIntegerCollection() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, 0); assertThat(max).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 8, 13, 21); assertThat(max).hasValue(21.0); numbers.add(34); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfLongCollection() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, 0); assertThat(max).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L); assertThat(max).hasValue(21.0); numbers.add(34L); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfFloatCollection() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, 0); assertThat(max).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f); assertThat(max).hasValue(21.0); numbers.add(34f); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfDoubleCollection() { ObservableList<Double> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, 0); assertThat(max).hasValue(0.0); numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d); assertThat(max).hasValue(21.0); numbers.add(34d); assertThat(max).hasValue(34.0); }
@Test public void testAverageOfIntegerCollection() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, 0); assertThat(average).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 10, 21); assertThat(average).hasValue(7.0); numbers.add(42); assertThat(average).hasValue(12.0); }
@Test public void testAverageOfLongCollection() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, 0); assertThat(average).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 10L, 21L); assertThat(average).hasValue(7.0); numbers.add(42L); assertThat(average).hasValue(12.0); }
@Test public void testAverageOfFloatCollection() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, 0); assertThat(average).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 10f, 21f); assertThat(average).hasValue(7.0); numbers.add(42f); assertThat(average).hasValue(12.0); }
@Test public void testAverageOfDoubleCollection() { ObservableList<Double> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, 0); assertThat(average).hasValue(0.0); numbers.addAll(1d, 2d, 3d, 5d, 10d, 21d); assertThat(average).hasValue(7.0); numbers.add(42d); assertThat(average).hasValue(12.0); }
@Test public void testMinOfIntegerCollectionWithSupplier() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, () -> 0); assertThat(min).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 8, 13, 21); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfLongCollectionWithSupplier() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, () -> 0); assertThat(min).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfFloatCollectionWithSupplier() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, () -> 0); assertThat(min).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMinOfDoubleCollectionWithSupplier() { ObservableList<Double> numbers = FXCollections.observableArrayList(); NumberBinding min = CollectionBindings.min(numbers, () -> 0); assertThat(min).hasValue(0.0); numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d); assertThat(min).hasValue(1.0); numbers.remove(0); assertThat(min).hasValue(2.0); }
@Test public void testMaxOfIntegerCollectionWithSupplier() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, () -> 0); assertThat(max).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 8, 13, 21); assertThat(max).hasValue(21.0); numbers.add(34); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfLongCollectionWithSupplier() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, () -> 0); assertThat(max).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 8L, 13L, 21L); assertThat(max).hasValue(21.0); numbers.add(34L); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfFloatCollectionWithSupplier() { ObservableList<Float> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, () -> 0); assertThat(max).hasValue(0.0); numbers.addAll(1f, 2f, 3f, 5f, 8f, 13f, 21f); assertThat(max).hasValue(21.0); numbers.add(34f); assertThat(max).hasValue(34.0); }
@Test public void testMaxOfDoubleCollectionWithSupplier() { ObservableList<Double> numbers = FXCollections.observableArrayList(); NumberBinding max = CollectionBindings.max(numbers, () -> 0); assertThat(max).hasValue(0.0); numbers.addAll(1d, 2d, 3d, 5d, 8d, 13d, 21d); assertThat(max).hasValue(21.0); numbers.add(34d); assertThat(max).hasValue(34.0); }
@Test public void testAverageOfIntegerCollectionWithSupplier() { ObservableList<Integer> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, () -> 0); assertThat(average).hasValue(0.0); numbers.addAll(1, 2, 3, 5, 10, 21); assertThat(average).hasValue(7.0); numbers.add(42); assertThat(average).hasValue(12.0); }
@Test public void testAverageOfLongCollectionWithSupplier() { ObservableList<Long> numbers = FXCollections.observableArrayList(); NumberBinding average = CollectionBindings.average(numbers, () -> 0); assertThat(average).hasValue(0.0); numbers.addAll(1L, 2L, 3L, 5L, 10L, 21L); assertThat(average).hasValue(7.0); numbers.add(42L); assertThat(average).hasValue(12.0); }