Hi I am creating a custom Excel parsing marshaller tool, you can reference this: How can I call getter/setter for property marked with custom annotation?
What I need now is to be able to find all annotations, specifically how can I find ones that nested objects or inner classes, and then call that setter/getter.
For example:
public class MyOuterClass
{
private InnerClass innerObject;
public void setInnerObject (InnerClass innerObject)
{
this.innerObject = innerObject;
}
public InnerClass getInnerObject ()
{
return innerObject;
}
}
public class InnerClass
{
//I need to get this field and call its setter from the class passed in, so something like:
// MyOuterClass outClass; outClass.getInnerObject.setFieldIWant("field")
// OR outClass.getInnerObject.getFieldIWant
// But have to be able to do at run time, having no knowledge of the class inside
// This must also work for a nested class
@ExcelColumn
private String fieldIWant;
public void setFieldIWant(String fieldIWant)
{
this.fieldIWant = fieldIWant;
}
public String getFieldIWant ()
{
return fieldIWant;
}
}
Aucun commentaire:
Enregistrer un commentaire