Skip to content

Commit

Permalink
8313651: Add 'final' keyword to public property methods in controls
Browse files Browse the repository at this point in the history
Reviewed-by: jhendrikx, nlisker, kcr
  • Loading branch information
Andy Goryachev committed Sep 11, 2023
1 parent 325be56 commit 624fe86
Show file tree
Hide file tree
Showing 8 changed files with 266 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -315,8 +315,8 @@ public String getName() {
* @return the string converter property
* @since JavaFX 2.1
*/
public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
private ObjectProperty<StringConverter<T>> converter =
public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
private final ObjectProperty<StringConverter<T>> converter =
new SimpleObjectProperty<>(this, "converter", null);
public final void setConverter(StringConverter<T> value) { converterProperty().set(value); }
public final StringConverter<T> getConverter() {return converterProperty().get(); }
Expand All @@ -329,8 +329,8 @@ public String getName() {
* @return the value property
* @since JavaFX 2.1
*/
public ObjectProperty<T> valueProperty() { return value; }
private ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value") {
public final ObjectProperty<T> valueProperty() { return value; }
private final ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value") {
@Override protected void invalidated() {
super.invalidated();
fireEvent(new ActionEvent());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,10 @@ public ComboBox(ObservableList<T> items) {
/**
* The list of items to show within the ComboBox popup.
*/
private ObjectProperty<ObservableList<T>> items = new SimpleObjectProperty<>(this, "items");
private final ObjectProperty<ObservableList<T>> items = new SimpleObjectProperty<>(this, "items");
public final void setItems(ObservableList<T> value) { itemsProperty().set(value); }
public final ObservableList<T> getItems() {return items.get(); }
public ObjectProperty<ObservableList<T>> itemsProperty() { return items; }
public final ObjectProperty<ObservableList<T>> itemsProperty() { return items; }


// --- string converter
Expand All @@ -321,8 +321,8 @@ public ComboBox(ObservableList<T> items) {
* the input may be retrieved via the {@link #valueProperty() value} property.
* @return the converter property
*/
public ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
private ObjectProperty<StringConverter<T>> converter =
public final ObjectProperty<StringConverter<T>> converterProperty() { return converter; }
private final ObjectProperty<StringConverter<T>> converter =
new SimpleObjectProperty<>(this, "converter", ComboBox.<T>defaultStringConverter());
public final void setConverter(StringConverter<T> value) { converterProperty().set(value); }
public final StringConverter<T> getConverter() {return converterProperty().get(); }
Expand All @@ -334,11 +334,11 @@ public ComboBox(ObservableList<T> items) {
* rendering of items in the ComboBox. Refer to the {@link Cell} javadoc
* for more information on cell factories.
*/
private ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory =
private final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactory =
new SimpleObjectProperty<>(this, "cellFactory");
public final void setCellFactory(Callback<ListView<T>, ListCell<T>> value) { cellFactoryProperty().set(value); }
public final Callback<ListView<T>, ListCell<T>> getCellFactory() {return cellFactoryProperty().get(); }
public ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }
public final ObjectProperty<Callback<ListView<T>, ListCell<T>>> cellFactoryProperty() { return cellFactory; }


// --- button cell
Expand All @@ -350,8 +350,8 @@ public ComboBox(ObservableList<T> items) {
* @return the button cell property
* @since JavaFX 2.2
*/
public ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }
private ObjectProperty<ListCell<T>> buttonCell =
public final ObjectProperty<ListCell<T>> buttonCellProperty() { return buttonCell; }
private final ObjectProperty<ListCell<T>> buttonCell =
new SimpleObjectProperty<>(this, "buttonCell");
public final void setButtonCell(ListCell<T> value) { buttonCellProperty().set(value); }
public final ListCell<T> getButtonCell() {return buttonCellProperty().get(); }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -145,8 +145,8 @@ public ComboBoxBase() {
* either the value input by the user, or the last selected item.
* @return the value property
*/
public ObjectProperty<T> valueProperty() { return value; }
private ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value");
public final ObjectProperty<T> valueProperty() { return value; }
private final ObjectProperty<T> value = new SimpleObjectProperty<>(this, "value");

public final void setValue(T value) { valueProperty().set(value); }
public final T getValue() { return valueProperty().get(); }
Expand All @@ -162,10 +162,10 @@ public ComboBoxBase() {
* reset, along with any other relevant state.
* @return the editable property
*/
public BooleanProperty editableProperty() { return editable; }
public final BooleanProperty editableProperty() { return editable; }
public final void setEditable(boolean value) { editableProperty().set(value); }
public final boolean isEditable() { return editableProperty().get(); }
private BooleanProperty editable = new SimpleBooleanProperty(this, "editable", false) {
private final BooleanProperty editable = new SimpleBooleanProperty(this, "editable", false) {
@Override protected void invalidated() {
pseudoClassStateChanged(PSEUDO_CLASS_EDITABLE, get());
}
Expand All @@ -178,7 +178,7 @@ public ComboBoxBase() {
* currently visible on screen (although it may be hidden behind other windows).
*/
private ReadOnlyBooleanWrapper showing;
public ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }
public final ReadOnlyBooleanProperty showingProperty() { return showingPropertyImpl().getReadOnlyProperty(); }
public final boolean isShowing() { return showingPropertyImpl().get(); }
private void setShowing(boolean value) {
// these events will not fire if the showing property is bound
Expand Down Expand Up @@ -245,10 +245,10 @@ public String getName() {
* ComboBox and pressed.
* @return the armed property
*/
public BooleanProperty armedProperty() { return armed; }
public final BooleanProperty armedProperty() { return armed; }
private final void setArmed(boolean value) { armedProperty().set(value); }
public final boolean isArmed() { return armedProperty().get(); }
private BooleanProperty armed = new SimpleBooleanProperty(this, "armed", false) {
private final BooleanProperty armed = new SimpleBooleanProperty(this, "armed", false) {
@Override protected void invalidated() {
pseudoClassStateChanged(PSEUDO_CLASS_ARMED, get());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 2023, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -113,7 +113,7 @@ private void initialize() {
* This allows setting of the target Node.
* @return the Node that this label is to be associated with
*/
public ObjectProperty<Node> labelForProperty() {
public final ObjectProperty<Node> labelForProperty() {
if (labelFor == null) {
labelFor = new ObjectPropertyBase<>() {
Node oldValue = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -996,18 +996,18 @@ public void scrollTo(T object) {
*/
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;

public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
onScrollToProperty().set(value);
}

public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
if( onScrollTo != null ) {
return onScrollTo.get();
}
return null;
}

public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
if( onScrollTo == null ) {
onScrollTo = new ObjectPropertyBase<>() {
@Override protected void invalidated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1406,18 +1406,18 @@ public final ObjectProperty<Callback<TableView<S>, Boolean>> sortPolicyProperty(
*/
private ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSort;

public void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {
public final void setOnSort(EventHandler<SortEvent<TableView<S>>> value) {
onSortProperty().set(value);
}

public EventHandler<SortEvent<TableView<S>>> getOnSort() {
public final EventHandler<SortEvent<TableView<S>>> getOnSort() {
if( onSort != null ) {
return onSort.get();
}
return null;
}

public ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {
public final ObjectProperty<EventHandler<SortEvent<TableView<S>>>> onSortProperty() {
if( onSort == null ) {
onSort = new ObjectPropertyBase<>() {
@Override protected void invalidated() {
Expand Down Expand Up @@ -1507,18 +1507,18 @@ public void scrollTo(S object) {
*/
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;

public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
onScrollToProperty().set(value);
}

public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
if( onScrollTo != null ) {
return onScrollTo.get();
}
return null;
}

public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
if( onScrollTo == null ) {
onScrollTo = new ObjectPropertyBase<>() {
@Override
Expand Down Expand Up @@ -1566,18 +1566,18 @@ public void scrollToColumnIndex(int columnIndex) {
*/
private ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumn;

public void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {
public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TableColumn<S, ?>>> value) {
onScrollToColumnProperty().set(value);
}

public EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {
public final EventHandler<ScrollToEvent<TableColumn<S, ?>>> getOnScrollToColumn() {
if( onScrollToColumn != null ) {
return onScrollToColumn.get();
}
return null;
}

public ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {
public final ObjectProperty<EventHandler<ScrollToEvent<TableColumn<S, ?>>>> onScrollToColumnProperty() {
if( onScrollToColumn == null ) {
onScrollToColumn = new ObjectPropertyBase<>() {
@Override protected void invalidated() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1632,18 +1632,18 @@ public final ObjectProperty<Callback<TreeTableView<S>, Boolean>> sortPolicyPrope
*/
private ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSort;

public void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {
public final void setOnSort(EventHandler<SortEvent<TreeTableView<S>>> value) {
onSortProperty().set(value);
}

public EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {
public final EventHandler<SortEvent<TreeTableView<S>>> getOnSort() {
if( onSort != null ) {
return onSort.get();
}
return null;
}

public ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {
public final ObjectProperty<EventHandler<SortEvent<TreeTableView<S>>>> onSortProperty() {
if( onSort == null ) {
onSort = new ObjectPropertyBase<>() {
@Override protected void invalidated() {
Expand Down Expand Up @@ -1698,18 +1698,18 @@ public void scrollTo(int index) {
*/
private ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollTo;

public void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
public final void setOnScrollTo(EventHandler<ScrollToEvent<Integer>> value) {
onScrollToProperty().set(value);
}

public EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
public final EventHandler<ScrollToEvent<Integer>> getOnScrollTo() {
if( onScrollTo != null ) {
return onScrollTo.get();
}
return null;
}

public ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
public final ObjectProperty<EventHandler<ScrollToEvent<Integer>>> onScrollToProperty() {
if( onScrollTo == null ) {
onScrollTo = new ObjectPropertyBase<>() {
@Override protected void invalidated() {
Expand Down Expand Up @@ -1752,18 +1752,18 @@ public void scrollToColumnIndex(int columnIndex) {
*/
private ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumn;

public void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {
public final void setOnScrollToColumn(EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> value) {
onScrollToColumnProperty().set(value);
}

public EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {
public final EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>> getOnScrollToColumn() {
if( onScrollToColumn != null ) {
return onScrollToColumn.get();
}
return null;
}

public ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {
public final ObjectProperty<EventHandler<ScrollToEvent<TreeTableColumn<S, ?>>>> onScrollToColumnProperty() {
if( onScrollToColumn == null ) {
onScrollToColumn = new ObjectPropertyBase<>() {
@Override
Expand Down

1 comment on commit 624fe86

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.