I imagine that there has to be some way to use reflection to do what I want to do.
I need to be able to take a string at runtime that is of a certain class, for example:
string s = "mypackage.MySuperClass"
Then I may have an object of some type. It could be one of the following:
mypackage.MySuperClass obj = new mypackage.MySuperClass();
or
mypackage.MySubClass obj2 = new mypackage.MySubClass();
or
someotherpackage.SomeOtherClass obj3 = new someotherpackage.SomeOtherClass();
What I need to do is see if an object (which its type is determined at runtime), is equal to the string s (which is also determined at runtime via completely different means).
In the cases above I would want obj and obj2 to be the same type as s (since MySubClass is a subclass of MySuperClass), and obj3 would not.
Is there an easy way to do this in java? Possibly something using instanceOf?