It is hard for me to understand the simulated self type idiom
abstract class Foo<T extends Foo>
{
public abstract T doSomething();
}
and
abstract class Foo<T extends Foo<T>>
{
public abstract T doSomething();
}
In both cases doSomething() returns a type which is Foo or a sub type of Foo
So basically it says that the type parameter of T must extend Foo or be Foo.
Where do I need now the Foo<T> or in which cases do I need the second one instead of the first one? What do I am missing out?
I am looking for cases where the first one would not work but the second one would.