How to convert a java pojo to hashmap( and reverse) not using field names but instead custom keys in an efficient manner. for instance;
Customer:
- name = aaa
- surname = bbb
will be converted to hashmap with keys below.
Hashmap:
- mykey1 : aaa
- mykey2 : bbb
The solution should be generic and work for different objects (there will be key to property mapping definitions like name -> mykey1, surname->mykey2)
I have checked apache commons OGNL but did not quite understand how to get it work for such a situation.
Ps: I know this can be done with reflection, but I am asking a high level solution includings apis and frameworks.