King Amit
,
Greenhorn
Hello Guys,
I have a small doubt.
Is there anyway to get an object on runtime.
Something like this:
I have a class say Employee and has following properties name, addrees, id
Now i have an object of Employee but I have to get one of the property depending on certain conditon.
So it may be emp.getName() or emp.getID on runtime.
How do I achieve this?
Regards,
Amit
Jeff Verdegan
,
Bartender
staff
King Amit wrote:
Hello Guys,
I have a small doubt.
Is there anyway to get an object on runtime.
That's the only way to get an object.
Something like this:
I have a class say Employee and has following properties name, addrees, id
Now i have an object of Employee but I have to get one of the property depending on certain conditon.
So it may be emp.getName() or emp.getID on runtime.
How do I achieve this?
It's hard to say without more details. Depending on your specific requirements and use cases, it might be as simple as
Or it might be that you'll want to use reflection or JavaBeans property introspection to get a property based on its name that isn't known until runtime.
King Amit
,
Greenhorn
No its not that simple actually.
There are hundred of properties and too multilevel.
I have to use these properties to be compared for their values depending upon what property user selects at runtime.
so it may be emp.getName.getLastName
or if he chooses country's zip code
it would be emp.getCountry.getState.getZipCode()
Jeff Verdegan
,
Bartender
staff
Well, again, there's not much detail to go on, but based on what you've said, it sounds like a candidate for reflection or introspection.
William Brogden
,
Author and all-around good cowpoke
Are we talking about Java objects serialized somewhere that you want to read in and query?
It is really very simple if serialized objects are stored in a Serializable collection.
Bill
What are you doing? You are supposed to be reading this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com