标签:mode 兼容 bsp design override adapter handle ati oid
1.适配器模式
将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以在一起工作。//用一个处理方法区匹配相同接口不同实现下的相同的方法名
2.实例
public interface Adapter { public abstract void test() ; } public class Adaptee implements Adapter{ @Override public void test() { } } public interface Target { public abstract void handler(); } public class TargetImp implements Target{ private Adapter adapter; @Override public void handler() { adapter.test(); } public TargetImp(Adapter adapter) { super(); this.adapter = adapter; } } public class Client { public static void main(String[] args) { Adaptee adaptee = new Adaptee(); TargetImp targetImp = new TargetImp(adaptee); targetImp.handler(); } }
标签:mode 兼容 bsp design override adapter handle ati oid
原文地址:https://www.cnblogs.com/gg128/p/9555101.html