Suppose I\'m trying to write a function to return an instance of the current type. Is there a way to make T
refer to the exact subtype (so T
should
I found a way do this, it's sort of silly but it works:
In the top level class (A):
protected final T a(T type) {
return type
}
Assuming C extends B and B extends A.
Invoking:
C c = new C();
//Any order is fine and you have compile time safety and IDE assistance.
c.setA("a").a(c).setB("b").a(c).setC("c");