I\'m experimenting with using generics to support a configurable structure of delegating objects (decorators, wrappers). I want to build a chain of delegators that implement
It looks like this is what you are trying to do.
static interface Delegator {
}
static class DelegatorChain, C> {
}
static interface Foo {
}
static class FooDelegator implements Delegator, Foo {
}
public static void main(String[] args) {
DelegatorChain chain = new DelegatorChain();
}
Your initial example does not compile because the types are not correct. The Generic type in DelegatorChain is a "FooDelegator" but the generic type required in the Delegator is "Foo". You'll need the extra generic type parameter that i provided in my answer to make it work as you intended.
You could also leave the constraint off entirely on DelegatorChain i.e. DelegatorChain.