Skip to content
Advertisement

Override generic method with more narrow parametrization

What I have:

I have a generic method which I want to override:

JavaScript

What I want:

There will be few classes that extend C-class and narrow parametrization. Example:

JavaScript

Question:

How can I achieve that?

EDIT:

Class C has many heirs: D, F, G, H… Each of those classes has the single method f(T param). And for each of those method I need T will be different heir of Z class in each case.

So I decide that I can set common API in C-class with help of generics. But if its impossible, maybe other way?

Advertisement

Answer

Parameterizing your classes could be a solution:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement