我有一个泛型 CHILDITEMS 的 ObservableList,其中<CHILDITEMS extends PlanItem>
. 我怎么知道 ObservableList 在运行时是什么类型?
/*Get a reference to the child items of the currently viewed item.*/
ObservableList<CHILDITEMS> childItems = (ObservableList<CHILDITEMS>) viewing.getChildItems();
/*Set the child items label to the type of the child items.*/
childItemsLabel.setText("Name of CHILDITEMS class");
我不能使用 getFields 因为 CHILDITEMS 并不是一个真正的字段。在 ObservableList.class 上使用 getType 只会返回泛型类型“E”,而不是在运行时返回的类型。
CHILDITEM 类型可以是 Goal、Objective、Strategy 或 Task。我想知道它在运行时是什么。