静态代理模式
package proxystatid;
public class StaticProxy {
public static void main(String[] args) {
You you = new You();
new Thread(()-> System.out.println("我爱你")).start();
new WeddingCompany(new You()).HappyMarry();
}
}
interface Marry{
void HappyMarry();
}
class You implements Marry{
@Override
public void HappyMarry() {
System.out.println("佳佳要结婚了,超级开心");
}
}
class WeddingCompany implements Marry{
private Marry target;
public WeddingCompany(Marry target){
this.target = target;
}
@Override
public void HappyMarry() {
before();
this.target.HappyMarry();
after();
}
private void after() {
System.out.println("结婚之后,收钱钱");
}
private void before(){
System.out.println("结婚之前,布置现场");
}
}