What should be a best way to create key/value pairs for all the string instance variables of a class? Is there any library exists doing such a task?
I am doing the same using a reflection based backward look-up. But it seems doing to much work.
For example:
I have a class
public class Account implements ManagedEntity {
private String accountNumber;
public Account(String accountNumber) {
this.accountNumber = accountNumber;
}
}
If an instance of Account
class is created like blelow,
Account ac = new Account("abc");
The output map should be like: [{"accountNumber", "abc"}].