Relative Content

Tag Archive for javagenerics

Java Generic wildcard misunderstanding [duplicate]

This question already has answers here: Generic wildcard types should not be used in return parameters (3 answers) Closed 2 days ago. Having this: public <T extends DataAgent> DataProcessor<? extends DataAgent> resolveProcessor( final String response, T dAgent) throws Exception { if (dAgent.getType() == RESULT_TYPE.INLINE) { return InlineParser.parse(response, (InlineDataAgent) dAgent); } return DefaultParser.parse(response, (DefaultDataAgent) dAgent); } […]

Not that simple Java recursive generics question

I have many interfaces (Foo and Bar), abstract classes implementing those interfaces (AbstractFoo and AbstractBar), and classes extending those abstract classes (FooImpl1, FooImpl2, BarImpl1 and BarImpl2). The interfaces are generics and parameters are pointing each others. Everything is compiling until I use a method from a generic field in the constructor of AbstractBar class (this.foo.addBar(this);).