给定以下方法:
public <E> void bindContentBidirectional(final String fieldPath,
final String itemFieldPath, final Class<?> itemFieldPathType,
final ObservableList<E> list, final Class<E> listValueType,
final SelectionModel<E> selectionModel,
final String selectionModelItemMasterPath)
我的理解是否正确,如果我有ObservableList<PrintablePredicate<SomeClass>>
以下类型:
final ObservableList<E> list
(也就是说,E = PrintablePredicate<SomeClass>
这永远不会起作用,因为对于下一个参数:
final Class<E> listValueType)
我只能写 PrintablePredicate.class 而不是 PrintablePredicate.class 因为泛型类型没有被具体化。换句话说,bindContentBidirectional 的给定方法签名与所有 E 不兼容,因此 E 具有泛型类型参数。
将它们放在一个具体的代码场景中,假设我们有:
@FXML private CheckListView<PrintablePredicate<Miner>> profileConditions;
private MinerMonitorProfile minerMonitorProfile;
private void initialize() {
BeanPathAdapter<MinerMonitorProfile> minerMonitorProfileBPA = new BeanPathAdapter<> (this.minerMonitorProfile);
minerMonitorProfileBPA.bindContentBidirectional("conditions", null, String.class, this.profileConditions.getItems(), PrintablePredicate.class, null, null);
}
编译器说:
bindContentBidirectional(String, String, Class<?>, ObservableList<E>, Class<E>, SelectionModel<E>, String)
类型中的方法BeanPathAdapter<MinerMonitorProfile>
不适用于参数(String
,null
,Class<String>
,ObservableList<PrintablePredicate<Miner>>
,Class<PrintablePredicate>
,null
,null
)
有没有办法解决?谢谢!
注意:this.profileConditions.getItems()
返回类型:ObservableList<PrintablePredicate<Miner>>
进一步注意,参数化方法调用如下:
minerMonitorProfileBPA.<PrintablePredicate<Miner>>bindContentBidirectional("conditions", null, String.class, this.profileConditions.getItems(), PrintablePredicate.class, null, null);
不能缓解问题。