2

I have a class File which is being extended by two other classes CopyFile and DeleteFile.

class File {
    private String filePath;
    /** Setters and getters **/
}

class CopyFile {
    private String destinationPath;
    /**setters and getters**/
}

class DeleteFile {
} 

Now I am trying to bind this to a table viewer:

ViewerSupport.bind(tableViewer, new WritableList(realm,
            fileDetailsList, File.class),PojoProperties.values(File.class,
                    new String[] { "filePath","destinationPath"}));

I want to show destinationPath when file is an instance of CopyFile and null or "" when it is an instance of DeleteFile.

But when I am running this it is throwing an error:

Could not find property with name destinationPath in class File

Please help me out this and tell me how to implement DataBinding in case of inheritance.

Baz
  • 36,440
  • 11
  • 68
  • 94
saurabh
  • 257
  • 1
  • 3
  • 12

1 Answers1

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.

unique_ptr
  • 586
  • 1
  • 8
  • 22