I have following sample that cannot compile and produces Error:() java: type argument GroupOfPartsDecorImpl<V> is not within bounds of type-variable GOP
. Code is the following:
class MainContainerGroupPartDecorator<V, GOP extends GroupOfParts<V, PartDecorator<V, ? extends Part<V>>>>
extends BaseContainerGroupPartDecorator<V, GOP> {
public static <V> MainContainerGroupPartDecorator<V, GroupOfPartsDecorImpl<V>> getInstance() {
return null;
}
}
class BaseContainerGroupPartDecorator<V, GOP extends GroupOfParts<V, ?>> {
void something() {}
}
class GroupOfPartsDecorImpl<V> implements GroupOfParts<V, PartDecorator<V, PartImpl1<V>>> {
@Override
public Collection<PartDecorator<V, PartImpl1<V>>> getParts() {
return null;
}
}
interface GroupOfParts<V, P extends Part<V>> {
Collection<P> getParts();
}
class PartDecorator<V, P extends Part<V>> implements Part<V> {
@Override
public V getId() {
return null;
}
}
class PartImpl1<V> implements Part<V> {
@Override
public V getId() {
return null;
}
}
Since GOP is GOP extends GroupOfParts<V, PartDecorator<V, ? extends Part<V>>>
and GroupOfPartsDecorImpl should be in the end GroupOfParts<V, PartDecorator<V, Part<V>>
why this error shows up?