Java implementation of default adapter (Adapter) mode [00 original]__java

Source: Internet
Author: User
Tags stub
The principle of this pattern is very simple, please see the example below.

1. Class Diagram

2. Java Implementation CodePackage cn.edu.ynu.sei.defaultAdapter;

/**
* Interface a<br>
* This interface has 5 methods, F1~f5
*
* @author 88250
* @version 1.0.0, 2007-8-31
*/
public interface Interfacea
{
public void F1 ();

public void F2 ();

public void F3 ();

public void F4 ();

public void F5 ();
}

Package cn.edu.ynu.sei.defaultAdapter;

/**
* Default Adapter role <br>
* This abstract class provides a default implementation for <code>InterfaceA</code>
*
* @author 88250
* @version 1.0.0, 2007-8-31
*/
Public abstract class Adapterc implements Interfacea
{

@Override
public void F1 ()
{
TODO auto-generated Method Stub

}

@Override
public void F2 ()
{
TODO auto-generated Method Stub

}

@Override
public void F3 ()
{
TODO auto-generated Method Stub

}

@Override
public void F4 ()
{
TODO auto-generated Method Stub

}

@Override
public void F5 ()
{
TODO auto-generated Method Stub

}

}

Package cn.edu.ynu.sei.defaultAdapter;

/**
* Inherited from <code>adapterc</code&gt, and F1 ()
*
* @author 88250
* @version 1.0.0, 2007-8-31
*/
public class CLASSB extends Adapterc
{
@Override
public void F1 ()
{
Overwrite implementation
}
}

3. SummaryThis is the "mediocre" form of the adapter pattern, which allows the class to be inspected without implementing the part of the interface that is not needed. In Java, the implementation of this pattern using the interface and the characteristics of abstract classes, about their characteristics, we must all have their own understanding and experience bar:-)

4. Reference Documents"Design Patterns", "Java and 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: info-contact@alibabacloud.com 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.