【发布时间】:2015-06-25 20:36:14
【问题描述】:
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 个警告。
【问题讨论】:
-
@suppress 注释
-
不要给东西
raw类型指定类型ArrayList<>与ArrayList<String>...
标签: java generics javafx warnings unchecked