I know it's possible to add multiple constraints to a Generic class definition, e.g.:
class Example<I extends Object & Comparable<Object>>{}
But I want a generic (MyGeneric
) that takes another generic (SomeGeneric<T>
) as its type parameter, and to constrain the type parameter (T
) of that generic (e.g. T extends SomeClass
).
Important, I need to know the types of both SomeGeneric
and SomeClass
from inside the class (G
and T
need to both be bound). For example, imagine something like this:
class MyGeneric<G extends SomeGeneric<T>, T extends SomeClass>
{
public G returnSomeGenericImpl(){}
public T returnSomeClassImpl(){}
}
Question: The above works, but I would prefer if my class had only one type parameter, to make life easier for implementers of my class. Is there a way of doing this?
Something like this would be nice (but this particular code is incorrect):
class MyGeneric<G extends SomeGeneric<T extends SomeClass>>
{
public G returnSomeGenericImpl(){}
public T returnSomeClassImpl(){}
}
If I wasn't clear, I'll gladly try to clarify my intent.