I am trying to reorganize a class and a set of subclasses, where the type M really extends something, although we know that it must be a subclass of a certain type. This type is parameterized, and I would like its parameterized types to be available for subclasses that already have values ββfor M.
Is there a way to define this class without having to include redundant K and V generic types in the parameter list. I would like the compiler to be able to infer them from the fact that M maps to subclasses.
public abstract class NewParametrized<K, V, M extends SomeParametrized<K, V>> {
public void someMethodThatTakesKAndV(K k1, V v1) { }
}
In other words, I would like the class declaration to look something like this:
public class NewParametrized<M extends SomeParametrized<K, V>> {
And types K and V will be deduced from the definition of M.
source
share