I have a POJO, and a (currently not-yet-built) class that will return Lists of it. I’d like to automatically generate the code necessary for the POJO to be accessed as a Map. Is this a good idea, is it possible to do automatically, and do I need to do this manually for every POJO I want to treat this way?
Thanks,
Andy
You can use Commons BeanUtils
BeanMapfor this.Update: since that’s not an option due to some apparent library dependency problems in Android, here’s a basic kickoff example how you could do it with little help of Reflection API:
If
java.beansAPI were available, then you could just do: