I working on a huge code base which has a huge class with many private members and public and private methods. I want to create a derived class from this base class that will have all same members and methods, except that one of its public methods will have a line commented. How can I do that?
I thought of overriding that method, but that method accesses many private members of the base class.
Below is the skeleton of what I want to do.
public class Base {
private var1;
private var2;
public toBeOverriden(){
processA(var1);
processB(var1);
processC(var1); // needs to be commented
processD(var2);
processE(var2);
}
}
Ideally I would like to do -
public class Derived extends Base{
@Override
public toBeOverriden(){
processA(var1);
processB(var1);
processD(var2);
processE(var2);
}
}
This is not possible because I cannot access private variables of the base class. Is there anything I can do without making all private members protected? Please note that overriding processC()
to empty is not an option because it can be used by other non-overriden methods.