I would like to create an interface that has the following methods:
public interface MyInterface {
public Class<X> getClass();
public void handle(X message);
}
Where X must be of the same type in both methods. The reason I need to do this is to receive messages that are blobs that need to be added to the appropriate class (using getClass), and then I would like to force developers to implement a descriptor method that accepts the appropriate class (instead assuming that there is one and use reflection to call it).
It seems that the only way to do this is to add a type parameter to the interface like this:
public interface MyInterface<T> {
...
}
but this is less than ideal due to cascading dependencies that require this type to be specified in other classes. Any suggestions? Thank!
Peter source