一、概述
1、定义
Convert the interface of a class into another interface clients expect.Adapter lets classes work together that couldn’t otherwise because of incompatible interfaces.(将一个类的接口变成客户端所期待的另一种接口,从而使原本因接口不匹配而无法在一起工作的两个类能够在一起工作)
2、通用类图
二、通用源码
Target目标角色:
该角色定义把其他类转换为何种接口,也就是我们的期望接口。
//目标角色接口
public interface Target {
//目标角色自己的方法
public void request();
}
//具体的目标角色
public class ConcreteTarget implements