I want to have a class that implements an interface that defines a specific subclass as a parameter.
public abstract Task implements TaskStatus<Task> { TaskStatus<T> listener; protected complete() {
But instead of a simple task, or, I want to guarantee that the arg type is used for a specific class that extends this one.
So, the best I came up with is:
public abstract Task<T extends Task> implements TaskStatus<T> { }
You can expand this by writing:
public class MyTask extends Task<MyTask> { }
But this is also true:
public class MyTask extends Task<SomeOtherTask> { }
And the callback call will explode ClassCastException. So, is this approach just wrong and broken, or is there a right way to do this, somehow I missed it?
source share