How to convert a Java object (bean) to key-value pairs (and vice versa)?
Posted
by
Shahbaz
on Stack Overflow
See other posts from Stack Overflow
or by Shahbaz
Published on 2009-04-11T07:37:51Z
Indexed on
2010/12/26
1:54 UTC
Read the original article
Hit count: 524
Say I have a very simple java object that only has some getXXX and setXXX properties. This object is used only to handle values, basically a record or a type-safe (and performant) map. I often need to covert this object to key value pairs (either strings or type safe) or convert from key value pairs to this object.
Other than reflection or manually writing code to do this conversion, what is the best way to achieve this?
An example might be sending this object over jms, without using the ObjectMessage type (or converting an incoming message to the right kind of object).
© Stack Overflow or respective owner