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()返回一个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个警告。
答案 0 :(得分:12)
请勿将您的TableView
和TableColumn
声明为原始类型。
换句话说,而不是
TableView personTable ;
TableColumn firstNameColumn ;
使用
TableView<Person> personTable ;
TableColumn<Person, String> firstNameColumn ;
等
不要压制这些警告,它们会帮助您调试问题。