I want to write global java method (using reflection) to convert object to CSV. when user gives map with field name as key and CSV header as value i want to create csv file using that data.
Suppose i have class User and User have address as attribute. Address is also object.
public class User {
private String userName;
private Address address;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Address getAddress() {
return address;
}
public void setAddress(Address address) {
this.address = address;
}
}
public class Address {
private String city;
private String country;
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}
I want to get user address city and country using reflection. suppose third party application pass address.city as key and i want to return city.
So what is the best way to find value using jave reflection.
Aucun commentaire:
Enregistrer un commentaire