So, am I just misunderstanding the spec, or is there no way to easily specify that a method should return the type of the object you called the method on?
Consider this example - I want to write a whole heap of methods in an abstract superclass, but I want each method to return the type of the subclass:
public abstract class A { <this> withYear(int year) { // implementation } } public class B extends A { } B b = new B().withYear(2006);
But, there is no <this> part in generics. The closest I could get was to generify the whole type (A) based on its subclass (B). But thats not really what I want to do at all.
Am I missing something?