An initial discussion of the Java design pattern in adapter mode

Source: Internet
Author: User

1. Overview

Transforms the interface of one class into another interface that the customer wants. The adapter mode makes it possible to work together those classes that would otherwise not work together because of incompatible interfaces.

2. Issues to solve

That is, the adapter mode makes it possible for those classes that cannot work together because the interface is incompatible.

Here are two very vivid examples.

3. Roles in the pattern

3.1 Destination Interface (target): the interface that the customer expects. The target can be a specific or abstract class, or it can be an interface.

3.2 Classes that need to be adapted (Adaptee): A class or an adapter class that needs to be adapted.

3.3 Adapter (Adapter): Converts the original interface into a target interface by wrapping an object that needs to be adapted.

4. How to Implement

(1) Class of Adapter mode (implemented with inheritance)

(2) object adapter (implemented by object combination)

An initial discussion of the Java design pattern in adapter mode

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.