设计模式--结构模式--适配器模式--Java适配器intent--目的?Convertthe interface of a class into another
设计模式--结构模式--适配器模式--Java
适配器intent--目的?Convertthe interface of a class into another interface clients expect. Adapter letsclasses work together that couldn't otherwise because of incompatibleinterfaces.?将一个类的接口转换为客户端所期望的接口。?Adapter模式使两个不兼容的两个接口可以一起工作。 Applicability---适用范围?you want to use an existing class, and its interfacedoes not match the one you need. ?你想使用一个现有类,但是它的接口并不适用你的需求。 ?you want to create a reusable class that cooperates withunrelated or unforeseen classes, that is, classes that don't necessarily havecompatible interfaces. ?你想创建一个可重用的类,使那些没有关系或者不可预见的类协同工作。 ?(object adapter only) you need to useseveral existing subclasses, but it's impractical to adapt their interface by subclassingevery one. An object adapter can adapt the interface of its parent class. ?(仅适用对象适配器)你想使用几个现存的子类,但是不可能对每一个都子类化以匹配它们的接口。一个对象适配器可以适配他的父类接口。 分类?简单适配器?对象适配器?类适配器