`

Adapter

 
阅读更多
Adapter


Intent
  Convert the interface of a class into another interface that clients expect.Adatper let classes work together that couldn't otherwise because of incompatible interfaces.


Applicability
  Use Adapter pattern when
1)you want to use an existing class,and its interface does not match what you need.

Structure
Object Adapter


Class Adapter




Participant
1)Target
  defines the domain-specific interface that Client expects.


2)Client
  collaborates with objects conforming to the Target interface.

3)Adaptee
  defines an existing interface that needs adapting.

4)Adapter
  adapts the interface of adaptee to the Target interface  


Consequences
  Class adapter and Object adapter has different trade-offs.
for class adapter:
1)lets Adapter override some of Adaptee's behavior, since Adapter is a subclass of
Adaptee

2)adapts Adaptee to Target by committing to a concrete Adapter class. As a
consequence, a class adapter won't work when we want to adapt a class and all its
subclasses

3) introduces only one object,and no additional pointer indirection is needed to get to adaptee..

for Object adapter:
1)Let a single adapter work with many adaptees-that is,the adaptee itself and all of its subclasses(if any).The Adapter can also add functionality to all adaptees at once.

2) Makes it harder to override Adaptee behavior.It will require subclassing Adaptee and making Adapter refer to the subclass rather than the Adaptee itself.


Two-way adapter.

Usage
Data transforming.
  • 大小: 19.5 KB
  • 大小: 22.9 KB
分享到:
评论

相关推荐

    Android中ListView+Adapter

    本文将深入探讨如何在Eclipse开发环境中利用ListView结合Adapter来展示数据。 首先,`ListView`是一个可滚动的视图,用于显示一组项目,每个项目都是一个单独的视图。它通过复用视图(ViewHolder模式)提高性能,...

    android之各种Adapter加载数据

    在Android开发中,Adapter是一个非常重要的组件,它起到了数据源与UI展示之间的桥梁作用。本文将深入探讨Android的Adapter机制,以及如何使用各种Adapter来加载数据。 首先,我们需要理解Adapter的基本概念。...

    sentinel-spring-webmvc-adapter-1.8.0-API文档-中文版.zip

    赠送jar包:sentinel-spring-webmvc-adapter-1.8.0.jar; 赠送原API文档:sentinel-spring-webmvc-adapter-1.8.0-javadoc.jar; 赠送源代码:sentinel-spring-webmvc-adapter-1.8.0-sources.jar; 赠送Maven依赖信息...

    Android自定义adapter的listview

    为了实现更加灵活和丰富的界面展示,我们通常需要对ListView进行自定义,这涉及到自定义Adapter的使用。自定义Adapter允许我们根据需求定制ListView的每一项视图,以适应不同的数据结构和界面设计。 首先,我们需要...

    hp usb network print adapter 驱动程序软件

    【标题】:“hp usb network print adapter 驱动程序软件” 在现代办公环境中,打印机扮演着至关重要的角色,而HP USB Network Print Adapter则是将打印机连接到网络中的关键设备。驱动程序是让硬件设备与操作系统...

    canal.adapter-1.1.4.zip

    【标题】"Canal Adapter 1.1.4版本" Canal是阿里巴巴开源的一个数据库增量日志订阅与消费组件,主要用于实现数据库的实时数据同步。Canal Adapter是其配套的适配器模块,用于将Canal捕获到的数据库变更事件转化为...

    usb 2.0 to fast ethernet adapter

    usb 2.0 to fast ethernet adapter win7 win8 xp驱动, 我的笔记本电脑由于使用时间较长,有线接口有点接触不良,所以上网买了个USB2.0 to Fast Ethernet Adapter 的适配器(将USB口转换为网口,可以插网线),首先...

    canal.adapter-1.1.6.zip

    【标题】"canal.adapter-1.1.6.zip" 提供的是Canal适配器的1.1.6版本,这是一个与数据库变更日志相关的软件组件。 【描述】"canal.adapter-1.1.6.zip" 指出这个压缩包包含的是Canal适配器的特定版本1.1.6,它是一个...

    sentinel-api-gateway-adapter-common-1.8.0-API文档-中文版.zip

    赠送jar包:sentinel-api-gateway-adapter-common-1.8.0.jar; 赠送原API文档:sentinel-api-gateway-adapter-common-1.8.0-javadoc.jar; 赠送源代码:sentinel-api-gateway-adapter-common-1.8.0-sources.jar; ...

    包装RecyclerView的Adapter实现上拉加载更多

    本文将详细讲解如何通过包装RecyclerView的Adapter来实现“上拉加载更多”的功能,这是一个常见的滚动监听机制,可以提升用户体验,让用户在浏览列表时无缝地加载更多数据。 首先,我们需要了解RecyclerView的基本...

    Apple USB Ethernet Adapter(苹果USB网卡驱动.zip

    Apple USB Ethernet Adapter是一款由苹果公司推出的硬件设备,用于在没有内置以太网接口或无线网络不可用时,为苹果设备提供有线网络连接。这款驱动程序适用于多种Windows操作系统,包括Windows 10、Windows 8.1、...

    SIMATIC_PC_Adapter_usbA2.rar

    SIMATIC PC Adapter是一款用于连接个人计算机(PC)与西门子PLC(可编程逻辑控制器)的硬件设备,以便进行编程、调试和监控任务。在早期的SIMATIC PLC系统中,许多型号并不具备以太网接口,因此必须依赖于MPI(Multi...

    Android自定义Adapter适配器

    在Android开发中,Adapter是一个至关重要的组件,它作为数据源与UI控件之间的桥梁,使得数据能够被适配并显示在界面中。本项目聚焦于自定义Adapter的实现,特别是如何将其应用于ListView的数据显示。 首先,理解...

    PC Adapter USB Drive

    "PC Adapter USB Drive" 是一个与个人计算机(PC)适配相关的USB驱动器产品。这种设备通常设计用于将不同类型的接口转换为USB接口,以便于在PC上使用。它可能是硬件适配器,允许用户将非USB设备(如串口或并口设备)...

    sentinel-spring-cloud-gateway-adapter-1.8.0-API文档-中文版.zip

    赠送jar包:sentinel-spring-cloud-gateway-adapter-1.8.0.jar; 赠送原API文档:sentinel-spring-cloud-gateway-adapter-1.8.0-javadoc.jar; 赠送源代码:sentinel-spring-cloud-gateway-adapter-1.8.0-sources....

    esper_adapter_reference

    ### Esper Adapter Reference:深入了解Esper 4.3.0中的Adapter技术 Esper是一个高性能的事件处理引擎,专为实时数据分析而设计。在Esper 4.3.0版本中,Adapter扮演着连接Esper与外部数据源或目标的关键角色。它们...

    Microsoft_LoopBack_Adapter_配置为系统的主网络适配器

    ### Microsoft LoopBack Adapter 配置为系统的主网络适配器 #### 一、概述 Microsoft LoopBack Adapter 是一种特殊的网络适配器,主要用于在没有实际网络连接的情况下进行网络功能的测试。这种虚拟适配器可以在不...

    Python库 | nonebot-adapter-cqhttp-2.0.0a14.tar.gz

    《Python库nonebot-adapter-cqhttp 2.0.0a14详解》 在IT行业中,Python作为一门强大的编程语言,拥有丰富的库支持,其中nonebot-adapter-cqhttp是一个重要的Python库,用于构建聊天机器人应用。本文将深入探讨...

    usb2.0 fast ethernet adapter 驱动

    USB 2.0 Fast Ethernet Adapter 是一款用于将计算机连接到以太网网络的硬件设备,它通过USB接口提供网络连接。QF9700是一款常见的USB 2.0以太网控制器,由不同的硬件制造商生产,适用于各种操作系统,包括Windows 10...

    SVNDrv.7z-SVN Adapter驱动

    SVNDrv.7z是一个包含SVN Adapter驱动的压缩包,这个驱动程序是为了解决在特定环境下Subversion(SVN)与操作系统交互时的问题。SVN是一个流行的版本控制系统,用于跟踪和管理软件项目的源代码和其他文件的变更。...

Global site tag (gtag.js) - Google Analytics