I'm trying to refactor a class and set of subclasses where the M type does extend anything, even though we know it has to be a subclass of a certain type. That type is parametrized and I would like its parametrized types to be available to subclasses that already have values for M.
Is there any way to define this class without having to include the redundant K and V generic types in the parameter list. I'd like to be able to have the compiler infer them from whatever M is mapped to by subclasses.
public abstract class NewParametrized<K, V, M extends SomeParametrized<K, V>> {
public void someMethodThatTakesKAndV(K k1, V v1) { }
}
In other words, I'd like the class declaration to look something like:
public class NewParametrized<M extends SomeParametrized<K, V>> {
And K and V's types would be inferred from the definition of M.