Say I have the string "Bar" and I want to know whether or not Bar is a valid object, and further, whether "Bar" extends "Foo". Would I be using Java reflection or is there a better way, like a database? and how would I do it?
Cheers
Say I have the string "Bar" and I want to know whether or not Bar is a valid object, and further, whether "Bar" extends "Foo". Would I be using Java reflection or is there a better way, like a database? and how would I do it?
Cheers
In case you don't know the package - only the class name, you could try this, using spring framework:
The two above methods give you the list of classes that are named "Bar" (they may be more than one!).
Then it's easier
Yes, reflection is the the answer: