Since there is no guarantee that it thisis actually an instance of a class Tor even extends it.
For example, consider the following:
public class T0 implements ExtendComparable<T0> {...}
public class T1 implements ExtendComparable<T0> {...}
T0 , : T0 extends ExtendComparable<T0> T0 T0. this T0, ; (T)this ( , (T0)this) .
T1 , T0 no T1, T T0. this T1, T1 T0. ,
ExtendedCompatible<T0>, . , Integer Double extend Number, (Integer) new Double(0.0) .
(T) (T0).
, T , , , . , - Java-, , , , " " Java- .
, , ExtendedCompatible , .
T, , this :
public abstract class ExtendedCompatible<T extends ExtendedCompatible<? super T>> {
private final T thiz;
protected ExtendedCompatible(final T thiz) {
if (this != thiz) throw new IllegalArgumentException("you must pass yourself");
this.thiz = thiz;
}
...
public class MyExtendedCompatible extends ExtendedCompatible<MyExtendedCompatible> {
public MyExtendedCompatible() {
super(this);
}
}
, , - / this .
T (this):
protected abstract T getThiz();
protected MyChildClass getThiz() { return this; }