标签:
public interface Implementor{
void operationImpl();
}
publicclassConcreteImplementorA implements Implementor{
@Override
publicvoid operationImpl(){
//具体实现
}
}
publicclassConcreteImplementorB implements Implementor{
@Override
publicvoid operationImpl(){
//具体实现
}
}
public abstract classAbstraction{
privateImplementor implementor;
publicAbstraction(Implementor implementor){
this.implementor = implementor;
}
publicvoid operation(){
implementor.operationImpl();
}
}
publicclassRefinedAbstraction extends Abstraction{
publicRefinedAbstraction(Implementor implementor){
super(implementor);
}
publicvoid refinedOperation(){
//对 Abstraction 中的 operation 方法进行扩展
}
}
标签:
原文地址:http://www.cnblogs.com/Doing-what-I-love/p/5621173.html