Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Class<? extends Callable<Integer>> clazz = (Class<? extends Callable<Integer>>) Class.forName(options.valueOf(className)).asSubclass(Callable.class);
- Class<Callable<Integer>> classCI = ...;
- Class<? extends Callable<Integer>> clazz =
- Class.forName(options.valueOf(className))
- .asSubclass(classCI);
- Class<Callable<Integer>> classCI = (Class<Callable<Integer>>)Callable.class;
- Object o = ...;
- String s1 = (String)o; // may fail, no javac warning
- String s2 = String.class.cast(o); // may fail, no javac warning
- @SuppressWarning( "unchecked" )
- Class<? Callable<Integer>> getClass(String className)
- {
- Class clazz = Class.forName(className);
- via reflection, check generic super interfaces of clazz
- if there's no Callable<Integer> super interface
- throw "className is not a Callable<Integer>"
- // we have *checked*, the following cast is safe
- return (Class<? Callable<Integer>>)clazz;
- }
Add Comment
Please, Sign In to add comment