对象适配器模式
2016-06-16 10:45
197 查看
public class Source{
public void method1(){
System.out.println("this is a method1");
}
}
public interface Targetable{
public void method1();
public void method2();
}
public class Wrapper implemenets Targetable{
private Source source;
public Targetable(Source source){
this.source = source
}
@Override
public void method1(){
System.out.println("this is original method1");
}
@Override
public void method2(){
System.out.println("this is the method2");
}
}
public class TestWrapper{
public static void main(){
Source source = new Source();
Targetable targeable = new Wrapper(source);
targetable.method1();
targetable.method2();
}
}
public void method1(){
System.out.println("this is a method1");
}
}
public interface Targetable{
public void method1();
public void method2();
}
public class Wrapper implemenets Targetable{
private Source source;
public Targetable(Source source){
this.source = source
}
@Override
public void method1(){
System.out.println("this is original method1");
}
@Override
public void method2(){
System.out.println("this is the method2");
}
}
public class TestWrapper{
public static void main(){
Source source = new Source();
Targetable targeable = new Wrapper(source);
targetable.method1();
targetable.method2();
}
}
相关文章推荐
- 设计模式-适配器模式
- 适配器模式
- java适配器模式
- 【GOF23设计模式】_适配器模式、对象适配器、类适配器、开发中场景JAVA235
- 【设计模式】适配器模式
- 设计模式之适配器模式
- php设计模式之五__适配器模式
- 7种结构型模式之:适配器模式(Adapter):类适配器、对象适配器
- java适配器模式
- 适配器模式(对象适配器)
- 235. Lowest Common Ancestor of a Binary Search Tree
- python的学习笔记之对文件、目录的操作
- linux下查看内存使用情况的方法总结(转)
- LTE PUCCH
- 在ARM 7A平台上编译OpenBTS
- ios立方体旋转动画
- 传感器
- iOS日志获取和实时浏览器显示日志
- Java源代码分析之Stack栈
- Scalaz(45)- concurrency :Task-函数式多线程编程核心配件