My favorites | Sign in
Project Home Downloads Wiki Issues Source
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 16: AnnotationEntryParser not compatible with inheritance
1 person starred this issue and may be notified of changes. Back to list
Status:  New
Owner:  ----


 
Reported by scotto.a...@gmail.com, Jun 11, 2014
I was trying to use the annotation MapToColumn in my User class.
But it didn't work and I had troubles figuring out why.
Eventually I did, only by reading the code, in particular `AnnotationEntryParser#fillObject`.


The problem is that I have a hierarchy Actor <= User
with some annotated fields in the superclass and some in the subclass.
And it turns out that #fillObject uses `entry.getClass().getDeclaredFields()`
which does not access fields in superclasses.
Fair enough to me, as I see that #getFields can access fields in superclasses but only public ones.

So, I think this just needs to be clarified in the wiki page:
https://code.google.com/p/jcsv/wiki/CSVReader#Create_Java_objects_using_annotations


Btw, I/m on v1.4.0.

Thx

AS


Example
-------

public class AnnotatedPerson {

	  @MapToColumn(column=0)
	  protected String firstname;
	  
	  @MapToColumn(column=1)
	  protected String lastname;
	  
	
	  @Override
	  public String toString() {
	    return String.format("%s %s  years", firstname, lastname);
	  }

public class Employee extends AnnotatedPerson {

	@MapToColumn(column=2)
	private int age;
  
	@Override
	public String toString() {
		return super.toString() + " " + age;
	}
  }


Powered by Google Project Hosting