I'm trying to extract all classes that implement an interface and put these in a Set. However, that interface is Parameterized and I'd like to communicate that it's all subclasses, regardless of their "parameter" I want, using a wildcard or something like that. However, I still need access to that parameter when going through the Set. (Btw I'm using the Reflections library)
The interface I'm trying to get subclasses of:
public interface Shouter<T> {
void shout(T dataObj);
}
What I'm trying to do (which I can't get to work)
private static Set<Class<? extends Shouter<?>>> extractShouters(String rootPackage) {
Reflections reflections = new Reflections(rootPackage);
return (Set<Class<? extends Shouter<?>>>) reflections.getSubTypesOf(Shouter<?>.class);
}
I'm getting an error in the last bit there, the "Shouter<?>.class", and I know that what I've written wont compile but I don't know how else. Now, I'm relatively new to Reflections, so I don't know if just addressing it as RAW would solve it and still give me access to the parameter.
The Set I mentioned earlier:
private Set<Class<? extends Listening<?>>> listeners;
private Set<Class<? extends Shouter<?>>> shouters;