I would like to use a generic class as a type parameter for another generic class.
At first my class definition was like this:
class Foo<T, R extends BaseDto> {} Then my requirements changed and I had to use a wrapper/holder class for my R type
My attempt so far: (Gives compile-time error: class or interface expected on Bar<R>)
class Bar<T extends BaseDto> { private T dto; public Bar(T dto) { this.dto= dto; } // getters and setters } class Foo<T, Bar<R>> { private T entity; private R dto; // getters and setters } I can not use it as Foo<T, Object> because then the clients using this class would not know that they actually need a cast from Object to Bar.
How would I implement such behaviour?