I'm building a network request util using enum but I can't figure out how to parameterize it:
public enum Request {
ENDPOINT_1 (FOO.class, "https://bar.com/foo");
ENDPOINT_2 (BAR.class, "https://bar.com/bar");
// How can I make Class<?> a template parameter here?
private final Class<?> className;
private final String url;
Endpoint(Class<Class> className, String url) {
this.className = className;
this.url = url;
}
// and here?
Class<?> sendHttpRequest() {
// Will return an object of type this.className
}
}
There's somewhat similar question for enums but I want it to work for class.