I'm requesting an annotation, I'll call it @ThisType, that can be attached to the return type of an instance method declared to return the type of the class containing the method definition.
For example:
abstract class Animal {
public abstract @ThisType Animal copy();
}
I intend this annotation to have this effect on the IDE:
If an overriding method is created in a subclass, the return type is set to the subclass type.
For example, if I create a subclass Dog and use the Override Methods... action to override this method, the method that is created is:
@Override
public @ThisType Dog copy() {
return null;
}
It would also be useful to have a quick way to override all of the @ThisType methods.
This feature would make implementing fluent APIs with subclasses a bit easier.