there is
Map<Class<?>, AbstractClass> holder = new HashMap<>(); Is filled
final Reflections s = new Reflections("reflection.components"); for(Class c : s.getSubTypesOf(AbstractComp.class)) { holder.put(c, (AbstractComp) c.newInstance()); } Displays the class inside:
System.out.println(holder.get(Inner.class).getClass().getSimpleName()); Question: With each call, I need to get the component with its methods through an explicit type conversion: (Inner) holder.get(Inner.class) . How can I get this kind of application in code: holder.get(Inner.class).callMethod() without explicit type casting and without checking for instanceof, because java already knows what subTypes lie inside, and this means test the option of implicit type casting through generics or something else, but I still do not have enough brain to realize it.
Thank!