Skip to content

Commit 624fe86

Browse files
author
Andy Goryachev
committed
8313651: Add 'final' keyword to public property methods in controls
Reviewed-by: jhendrikx, nlisker, kcr
1 parent 325be56 commit 624fe86

File tree

8 files changed

+266
-44
lines changed

8 files changed

+266
-44
lines changed

modules/javafx.controls/src/main/java/javafx/scene/control/ChoiceBox.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -315,8 +315,8 @@ public String getName() {
315315
* @return the string converter property
316316
* @since JavaFX 2.1
317317
*/
318-
public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
319-
private ObjectProperty<StringConverter<T>> converter =
318+
public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
319+
private final ObjectProperty<StringConverter<T>> converter =
320320
new SimpleObjectProperty<>(this, "converter", null);
321321
public final void setConverter(StringConverter<T> value) { converterProperty().set(value); }
322322
public final StringConverter<T> getConverter() {return converterProperty().get(); }
@@ -329,8 +329,8 @@ public String getName() {
329329
* @return the value property
330330
* @since JavaFX 2.1
331331
*/
332-
public ObjectProperty<T> valueProperty() { return value; }
333-
private ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value") {
332+
public final ObjectProperty<T> valueProperty() { return value; }
333+
private final ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value") {
334334
@Override protected void invalidated() {
335335
super.invalidated();
336336
fireEvent(new ActionEvent());

modules/javafx.controls/src/main/java/javafx/scene/control/ComboBox.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,10 @@ public ComboBox(ObservableList<T> items) {
308308
/**
309309
* The list of items to show within the ComboBox popup.
310310
*/
311-
private ObjectProperty<ObservableList<T>> items = new SimpleObjectProperty<>(this, "items");
311+
private final ObjectProperty<ObservableList<T>> items = new SimpleObjectProperty<>(this, "items");
312312
public final void setItems(ObservableList<T> value) { itemsProperty().set(value); }
313313
public final ObservableList<T> getItems() {return items.get(); }
314-
public ObjectProperty<ObservableList<T>> itemsProperty() { return items; }
314+
public final ObjectProperty<ObservableList<T>> itemsProperty() { return items; }
315315

316316

317317
// --- string converter
@@ -321,8 +321,8 @@ public ComboBox(ObservableList<T> items) {
321321
* the input may be retrieved via the {@link #valueProperty() value} property.
322322
* @return the converter property
323323
*/
324-
public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
325-
private ObjectProperty<StringConverter<T>> converter =
324+
public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
325+
private final ObjectProperty<StringConverter<T>> converter =
326326
new SimpleObjectProperty<>(this, "converter", ComboBox.<T>defaultStringConverter());
327327
public final void setConverter(StringConverter<T> value) { converterProperty().set(value); }
328328
public final StringConverter<T> getConverter() {return converterProperty().get(); }
@@ -334,11 +334,11 @@ public ComboBox(ObservableList<T> items) {
334334
* rendering of items in the ComboBox. Refer to the {@link Cell} javadoc
335335
* for more information on cell factories.
336336
*/
337-
private ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory =
337+
private final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory =
338338
new SimpleObjectProperty<>(this, "cellFactory");
339339
public final void setCellFactory(Callback<ListView<T>, ListCell<T>> value) { cellFactoryProperty().set(value); }
340340
public final Callback<ListView<T>, ListCell<T>> getCellFactory() {return cellFactoryProperty().get(); }
341-
public ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }
341+
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }
342342

343343

344344
// --- button cell
@@ -350,8 +350,8 @@ public ComboBox(ObservableList<T> items) {
350350
* @return the button cell property
351351
* @since JavaFX 2.2
352352
*/
353-
public ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }
354-
private ObjectProperty<ListCell<T>> buttonCell =
353+
public final ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }
354+
private final ObjectProperty<ListCell<T>> buttonCell =
355355
new SimpleObjectProperty<>(this, "buttonCell");
356356
public final void setButtonCell(ListCell<T> value) { buttonCellProperty().set(value); }
357357
public final ListCell<T> getButtonCell() {return buttonCellProperty().get(); }

modules/javafx.controls/src/main/java/javafx/scene/control/ComboBoxBase.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -145,8 +145,8 @@ public ComboBoxBase() {
145145
* either the value input by the user, or the last selected item.
146146
* @return the value property
147147
*/
148-
public ObjectProperty<T> valueProperty() { return value; }
149-
private ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value");
148+
public final ObjectProperty<T> valueProperty() { return value; }
149+
private final ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value");
150150

151151
public final void setValue(T value) { valueProperty().set(value); }
152152
public final T getValue() { return valueProperty().get(); }
@@ -162,10 +162,10 @@ public ComboBoxBase() {
162162
* reset, along with any other relevant state.
163163
* @return the editable property
164164
*/
165-
public BooleanProperty editableProperty() { return editable; }
165+
public final BooleanProperty editableProperty() { return editable; }
166166
public final void setEditable(boolean value) { editableProperty().set(value); }
167167
public final boolean isEditable() { return editableProperty().get(); }
168-
private BooleanProperty editable = new SimpleBooleanProperty(this, "editable", false) {
168+
private final BooleanProperty editable = new SimpleBooleanProperty(this, "editable", false) {
169169
@Override protected void invalidated() {
170170
pseudoClassStateChanged(PSEUDO_CLASS_EDITABLE, get());
171171
}
@@ -178,7 +178,7 @@ public ComboBoxBase() {
178178
* currently visible on screen (although it may be hidden behind other windows).
179179
*/
180180
private ReadOnlyBooleanWrapper showing;
181-
public ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }
181+
public final ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }
182182
public final boolean isShowing() { return showingPropertyImpl().get(); }
183183
private void setShowing(boolean value) {
184184
// these events will not fire if the showing property is bound
@@ -245,10 +245,10 @@ public String getName() {
245245
* ComboBox and pressed.
246246
* @return the armed property
247247
*/
248-
public BooleanProperty armedProperty() { return armed; }
248+
public final BooleanProperty armedProperty() { return armed; }
249249
private final void setArmed(boolean value) { armedProperty().set(value); }
250250
public final boolean isArmed() { return armedProperty().get(); }
251-
private BooleanProperty armed = new SimpleBooleanProperty(this, "armed", false) {
251+
private final BooleanProperty armed = new SimpleBooleanProperty(this, "armed", false) {
252252
@Override protected void invalidated() {
253253
pseudoClassStateChanged(PSEUDO_CLASS_ARMED, get());
254254
}

modules/javafx.controls/src/main/java/javafx/scene/control/Label.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -113,7 +113,7 @@ private void initialize() {
113113
* This allows setting of the target Node.
114114
* @return the Node that this label is to be associated with
115115
*/
116-
public ObjectProperty<Node> labelForProperty() {
116+
public final ObjectProperty<Node> labelForProperty() {
117117
if (labelFor == null) {
118118
labelFor = new ObjectPropertyBase<>() {
119119
Node oldValue = null;

modules/javafx.controls/src/main/java/javafx/scene/control/ListView.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,18 +996,18 @@ public void scrollTo(T object) {
996996
*/
997997
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;
998998

999-
public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
999+
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
10001000
onScrollToProperty().set(value);
10011001
}
10021002

1003-
public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
1003+
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
10041004
if( onScrollTo != null ) {
10051005
return onScrollTo.get();
10061006
}
10071007
return null;
10081008
}
10091009

1010-
public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
1010+
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
10111011
if( onScrollTo == null ) {
10121012
onScrollTo = new ObjectPropertyBase<>() {
10131013
@Override protected void invalidated() {

modules/javafx.controls/src/main/java/javafx/scene/control/TableView.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,18 +1406,18 @@ public final ObjectProperty<Callback<TableView<S>, Boolean>> sortPolicyProperty(
14061406
*/
14071407
private ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSort;
14081408

1409-
public void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {
1409+
public final void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {
14101410
onSortProperty().set(value);
14111411
}
14121412

1413-
public EventHandler<SortEvent<TableView<S>>> getOnSort() {
1413+
public final EventHandler<SortEvent<TableView<S>>> getOnSort() {
14141414
if( onSort != null ) {
14151415
return onSort.get();
14161416
}
14171417
return null;
14181418
}
14191419

1420-
public ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {
1420+
public final ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {
14211421
if( onSort == null ) {
14221422
onSort = new ObjectPropertyBase<>() {
14231423
@Override protected void invalidated() {
@@ -1507,18 +1507,18 @@ public void scrollTo(S object) {
15071507
*/
15081508
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;
15091509

1510-
public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
1510+
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
15111511
onScrollToProperty().set(value);
15121512
}
15131513

1514-
public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
1514+
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
15151515
if( onScrollTo != null ) {
15161516
return onScrollTo.get();
15171517
}
15181518
return null;
15191519
}
15201520

1521-
public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
1521+
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
15221522
if( onScrollTo == null ) {
15231523
onScrollTo = new ObjectPropertyBase<>() {
15241524
@Override
@@ -1566,18 +1566,18 @@ public void scrollToColumnIndex(int columnIndex) {
15661566
*/
15671567
private ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumn;
15681568

1569-
public void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {
1569+
public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {
15701570
onScrollToColumnProperty().set(value);
15711571
}
15721572

1573-
public EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {
1573+
public final EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {
15741574
if( onScrollToColumn != null ) {
15751575
return onScrollToColumn.get();
15761576
}
15771577
return null;
15781578
}
15791579

1580-
public ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {
1580+
public final ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {
15811581
if( onScrollToColumn == null ) {
15821582
onScrollToColumn = new ObjectPropertyBase<>() {
15831583
@Override protected void invalidated() {

modules/javafx.controls/src/main/java/javafx/scene/control/TreeTableView.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,18 +1632,18 @@ public final ObjectProperty<Callback<TreeTableView<S>, Boolean>> sortPolicyPrope
16321632
*/
16331633
private ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSort;
16341634

1635-
public void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {
1635+
public final void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {
16361636
onSortProperty().set(value);
16371637
}
16381638

1639-
public EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {
1639+
public final EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {
16401640
if( onSort != null ) {
16411641
return onSort.get();
16421642
}
16431643
return null;
16441644
}
16451645

1646-
public ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {
1646+
public final ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {
16471647
if( onSort == null ) {
16481648
onSort = new ObjectPropertyBase<>() {
16491649
@Override protected void invalidated() {
@@ -1698,18 +1698,18 @@ public void scrollTo(int index) {
16981698
*/
16991699
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;
17001700

1701-
public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
1701+
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
17021702
onScrollToProperty().set(value);
17031703
}
17041704

1705-
public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
1705+
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
17061706
if( onScrollTo != null ) {
17071707
return onScrollTo.get();
17081708
}
17091709
return null;
17101710
}
17111711

1712-
public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
1712+
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
17131713
if( onScrollTo == null ) {
17141714
onScrollTo = new ObjectPropertyBase<>() {
17151715
@Override protected void invalidated() {
@@ -1752,18 +1752,18 @@ public void scrollToColumnIndex(int columnIndex) {
17521752
*/
17531753
private ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumn;
17541754

1755-
public void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {
1755+
public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {
17561756
onScrollToColumnProperty().set(value);
17571757
}
17581758

1759-
public EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {
1759+
public final EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {
17601760
if( onScrollToColumn != null ) {
17611761
return onScrollToColumn.get();
17621762
}
17631763
return null;
17641764
}
17651765

1766-
public ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {
1766+
public final ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {
17671767
if( onScrollToColumn == null ) {
17681768
onScrollToColumn = new ObjectPropertyBase<>() {
17691769
@Override

0 commit comments

Comments
 (0)