19.结构型 - 适配器模式 (Adapter)
1.定义 将一个类的接口转换为客户期待的接口(通过Adapter达到兼容接口的目的) 2.UML类图 角色介绍 IAccessSDCardTarget : Target角色,定义了目标接口 TFCardAdaptee : Adaptee角色,需要适配的角色,将其接口适配为Target定义的接口 AccessAdapter : Adapter角色,这里为对象适配器角色,Adapter通过代理的方式与Adaptee连接 要点 Adapter需要实现Target接口,并且代理使用Adaptee对象 3.UML示例代码 /** * Copyright (C), 2016-2020 * FileName: IAccessSDCardTarget * Author: wei.zheng * Date: 2020/1/4 10:05 * Description: Target角色,抽象接口,读写SDCard */ public interface IAccessSDCardTarget { String readSDCard ( ) ; void writeSDCard ( String content ) ; } /** * Copyright (C), 2016-2020 * FileName: TFCardAdaptee * Author: wei.zheng * Date: 2020/1