我有一个班级File
,正在由另外两个班级CopyFile
和DeleteFile
进行扩展。
class File {
private String filePath;
/** Setters and getters **/
}
class CopyFile {
private String destinationPath;
/**setters and getters**/
}
class DeleteFile {
}
现在我正在尝试将其绑定到表查看器:
ViewerSupport.bind(tableViewer, new WritableList(realm,
fileDetailsList, File.class),PojoProperties.values(File.class,
new String[] { "filePath","destinationPath"}));
我希望当文件是CopyFile
和null
或""
的实例时,如果它是DeleteFile
的实例,则显示destinationPath。
但是当我运行它时,它会抛出一个错误:
在类File
中找不到名为destinationPath的属性
请帮我解决这个问题并告诉我如何在继承的情况下实现DataBinding。
答案 0 :(得分:0)
Please note that when you bind File.class
the property won't be found since it uses reflection and the property belongs to CopyFile.class
. binding is done with Beans or POJOs in order to observe their details.