Below is running fine:
ResultSetHandler<List<MyClass>> h = new BeanListHandler<MyClass>(MyClass.class);
Issue is that MyClass
is hard-coded. Above line is at centralized location and hence hard-coding is bad.
I have fully qualified class name of MyClass
i.e. com.company.vo.MyClass
Now I want to generate above ResultSetHandler
by converting incoming String to actual class.
Please help, I have tried:
Class<?> classObj = Class.forName("com.company.vo.MyClass");
ResultSetHandler<List<classObj>> h = new BeanListHandler<classObj>(classObj.class);
Which throws:
classObj cannot be resolved to a type
Thanks for reading.
>` should work for your purpose, although not type-safe.
– m0skit0 Mar 12 '15 at 09:47> h = new BeanListHandler
– Oli Mar 12 '15 at 10:09>(classObj);`. Having `IFoo` contain all of the methods that exist in the class that you expect.