I seems to be running into a compilation error with a generic interface. The goal is to create an interface for use in my test classes the defines the common methods of a domain class and a generated DTO class. I did some digging and none of the answers I have found so far seem applicable to what I am trying to do. Most of the answers either refer back to this: class not within type bounds or they suggest using wildcards which is not an option here.
When I try to compile, I get the following error:
[uberCompile] BrandDto.java:10: error: type argument T#1 is not within bounds of type-variable T#2
[uberCompile] public class BrandDto<T extends SubCollectionDto> implements IBrand<T> {
[uberCompile]
[uberCompile] where T#1,T#2 are type-variables:
[uberCompile] T#1 extends SubCollectionDto declared in class BrandDto
[uberCompile] T#2 extends ISubCollection declared in interface IBrand
My class structure looks like this:
interface IBrand<T extends ISubCollection>
interface ISubCollection
class Brand<T extends SubCollection>
extends Entity
implements IBrand<T>
class SubCollection
extends Entity
implements ISubCollection
The generated DTO classes look like:
class SubCollectionDto
implements ISubCollection
class BrandDto<T extends SubCollectionDto>
implements IBrand<T>
I'm really racking my brain trying to understand what I am doing wrong here. Any help would be greatly appreciated.