我如何摆脱这些(未检查的呼叫)警告?
How do i get rid of these (unchecked call) warnings?
warning: [unchecked] unchecked call to setCellValueFactory(Callback<CellDataFeatures<S,T>,ObservableValue<T>>) as a member of the raw type TableColumn column1.setCellValueFactory(new PropertyValueFactory<String, State>("name")); where S,T are type-variables:
S extends Object declared in class TableColumn
T extends Object declared in class TableColumn
代码:
column1.setCellValueFactory(new PropertyValueFactory<>("name"));
warning: [unchecked] unchecked call to add(E) as a member of the raw type List
transitionTable.getColumns().add(column1);
where E is a type-variable:
E extends Object declared in interface List
代码:
transitionTable.getColumns().add(column1);
warning: [unchecked] unchecked call to setAll(Collection<? extends E>) as a member of the raw type ObservableList
automatonSelection.getItems().setAll(automatonManager.getMachines());
where E is a type-variable:
E extends Object declared in interface ObservableList
代码:
automatonSelection.getItems().setAll(automatonManager.getMachines());
automatonSelection 是一个 ComboBox 和 getMachines() returns 一个 Automaton 类型的 LinkedList
warning: [unchecked] unchecked call to addListener(ChangeListener<? super T>) as a member of the raw type ObservableValue
automatonSelection.valueProperty().addListener((ObservableValue observable,
where T is a type-variable:
T extends Object declared in interface ObservableValue
代码:
automatonSelection.valueProperty().addListener((ObservableValue observable,
Object oldValue, Object newValue) -> {
stateChanged();
});
我试图修复其中的大部分警告并通过添加泛型设法做到了这一点,但我看不出如何修复其他 4 个警告。
不要将您的 TableView
和 TableColumn
声明为原始类型。
换句话说,而不是
TableView personTable ;
TableColumn firstNameColumn ;
使用
TableView<Person> personTable ;
TableColumn<Person, String> firstNameColumn ;
等等
不要抑制这些警告,它们会帮助您调试问题。
warning: [unchecked] unchecked call to setCellValueFactory(Callback<CellDataFeatures<S,T>,ObservableValue<T>>) as a member of the raw type TableColumn column1.setCellValueFactory(new PropertyValueFactory<String, State>("name")); where S,T are type-variables:
S extends Object declared in class TableColumn
T extends Object declared in class TableColumn
代码:
column1.setCellValueFactory(new PropertyValueFactory<>("name"));
warning: [unchecked] unchecked call to add(E) as a member of the raw type List
transitionTable.getColumns().add(column1);
where E is a type-variable:
E extends Object declared in interface List
代码:
transitionTable.getColumns().add(column1);
warning: [unchecked] unchecked call to setAll(Collection<? extends E>) as a member of the raw type ObservableList
automatonSelection.getItems().setAll(automatonManager.getMachines());
where E is a type-variable:
E extends Object declared in interface ObservableList
代码:
automatonSelection.getItems().setAll(automatonManager.getMachines());
automatonSelection 是一个 ComboBox 和 getMachines() returns 一个 Automaton 类型的 LinkedList
warning: [unchecked] unchecked call to addListener(ChangeListener<? super T>) as a member of the raw type ObservableValue
automatonSelection.valueProperty().addListener((ObservableValue observable,
where T is a type-variable:
T extends Object declared in interface ObservableValue
代码:
automatonSelection.valueProperty().addListener((ObservableValue observable,
Object oldValue, Object newValue) -> {
stateChanged();
});
我试图修复其中的大部分警告并通过添加泛型设法做到了这一点,但我看不出如何修复其他 4 个警告。
不要将您的 TableView
和 TableColumn
声明为原始类型。
换句话说,而不是
TableView personTable ;
TableColumn firstNameColumn ;
使用
TableView<Person> personTable ;
TableColumn<Person, String> firstNameColumn ;
等等
不要抑制这些警告,它们会帮助您调试问题。