Possible Duplicate:
Java reflection: Get concrete type of implemented generic interface
Say I have an interface:
public interface Monitor<T extends com.google.protobuf.Message>{
public void checkMessage(T message)
}
and a concrete implementation:
public class MyMonitor implements Monitor<GeneratedMessage>{
@Override
public void checkMessage(GeneratedMessage message){
//do something
}
}
I want to write a utility method that I can pass MyMonitor to that will return GeneratedMessage.class. Is there any way to do this? I have seen a couple of blogs that are sort of related to this, but most of them are related to extended classes.
Also, if it is possible, can I declare Monitor<GeneratedMessage> monitor = new MyMonitor();
and pass monitor to the same method, and get GeneratedMessage back?