Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1044635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:51:32+00:00 2026-05-16T15:51:32+00:00

I have an interface — EventHandler — that declares several methods. public interface EventHandler

  • 0

I have an interface — “EventHandler” — that declares several methods.

public interface EventHandler {
    void handleEvent1();

    void handleEvent2();

    void handleEvent3();

    void handleEvent4();
}

I also have a class — “EventHandlerAdapter” — that implements EventHandler. However, it doesn’t actually “implement” anything. The point is, if another class wants to implement EventHandler, but not all of its methods, it can simply extend EventHandlerAdapter and only override the methods it wants to.

public class EventHandlerAdapter implements EventHandler {
    public void handleEvent1() {}

    public void handleEvent2() {}

    public void handleEvent3() {}

    public void handleEvent4() {}
}

I’ve seen something like this on more than one occasion. The name “EventHandlerAdapter” suggests to me that it is an example of the adapter pattern… but is it really? I thought the point of an adapter was to translate an existing implementation into something else. I don’t see how this is the case here.

If it isn’t an example of the adapter pattern, what is it? Surely something like this has been identified.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:51:33+00:00Added an answer on May 16, 2026 at 3:51 pm

    No, this is not an example of an Adapter Pattern, as defined here:

    http://en.wikipedia.org/wiki/Adapter_pattern

    However, in Java Event handling, the term Adapter is frequently used as you mentioned. Even though the word “Adapter” is the same in both, they do not refer to the same thing. The Adapters that appear in the java.awt.event package are there to make it easy to create an event handler that handles only one method without having to write a bunch of empty methods. They are only shortcut classes.

    The Java Event API typically has consistent naming for these classes. When there is a SomeEvent event class, there is a SomeListener interface to listen to the event and a SomeAdapter class implementing the listener interface with empty methods. Not all events have all three of these parts, but there is consistency in the naming and function of the three.

    In the example you provided, I would rename the class EventAdapter to be consistent with the existing Java API.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have interface Foo public interface Foo { public void test(); } Class FooChild
I have interface IModule and several classes that implements it. In test i need
I have interface in service layer with several methods starting with Get and FxCop's
I have seen that if I have interface named interfaceABC. Example: public class ABController
If I have interface IFoo, and have several classes that implement it, what is
Let's say we have interface window_creator that responsible for creation of windows. For simplicity
I have an interface: public interface: IA { ... } and I try to
I have an Interface like this: namespace QuickRoutes.Model.Utilities { public interface IRoutesManager { bool
I have next interface public interface IMyInterface { string this[string key] { get; set;
I have interface: public interface CartService extends RemoteService{ <T extends ActionResponse> T execute(Action<T> action);

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.