设计模式-模板模式
作者:互联网
1.public interface TestTemplate {
Response doSomeThing();
}
2.
`public abstract class SayHelloAb implements TestTemplate {
@Override
public Response doSomeThing() {
log.info("Hello");
doAnother();
return null;
}
protected abstract Response doAnother();
}`
- ctrl+o 重写父类方法
public class DoSayHello extends SayHelloAb{
@Override
public Response doSomeThing() {
return super.doSomeThing();
}
@Override
protected Response doAnother() {
log.info("another hello");
return null;
}
}
@Autowired
TestTemplate doSayHello;
@Test
public void testModel(){
doSayHello.doSomeThing();
}
[main] INFO c.b.t.s.s.s.testTemp.SayHelloAb:11 - Hello
[main] INFO c.b.t.s.s.s.testTemp.DoSayHello:19 - another hello
标签:return,doSomeThing,模式,public,TestTemplate,Override,设计模式,Response,模板 来源: https://blog.csdn.net/qq_42662114/article/details/118929580