How can I restrict the implementation class of my Abstract class from modifying the scope of a method from protected to public?
For example : Suppose I have a Abstract Class
package com.rao.test;
public abstract class AbstractTEClass {
protected abstract void function1();
protected abstract void function2();
protected void doWork() //I want to call the abstract methods from this method.
{
function1(); //implementation classes will give implementation of these methods
function2();
}
}
Now, I have a implementation class which extends the above abstract class
package com.rao.test;
public class AbstractTEClassImpl extends AbstractTEClass {
@Override
public void function1() {
// TODO Auto-generated method stub
System.out.println("FUnction1");
}
@Override
public void function2() {
// TODO Auto-generated method stub
System.out.println("Function2");
}
public static void main(String[] args)
{
AbstractTEClassImpl objTEClass = new AbstractTEClassImpl();
objTEClass.doWork();
}
}
Notice here that I am changing the scope of the 2 abstract methods in the implementation class from protected to public, how can I restrict my implementation class from modifying the scope.
Any design changes or recommendation or patterns are welcome.